观察式子发现规律
n, N = map(int, input().split()) num = list(map(int, input().split())) sum1 = 0 for i in range(0, n-1): sum1 += (num[i+1] - num[i]) * (i+1) sum1 += (N-num[n-1])*n print(sum1)