def matrix_power(A,p): temp=A bench=p-1 ret=A while bench>0: if bench%2: ret=matrix_product(ret,temp) bench=bench//2 temp=matrix_product(temp,temp) return ret def matrix_product(A,B): ret=[[0 for i in range(len(B[0]))] for i in range(len(A))] for i in range(len(A)): for j in range(len(B[0])): s=0 for k in range(len(A[i])): s+=A[i][k]*B[k][j] ret[i][j]=s return ret n,c=map(int,input().split()) a=list(map(int,input().split())) A=[[0 for i in range(n)] for i in range(n)] b=[[1] for i in range(n)] for i in range(n): for j in range(i+1): A[i][j]=a[j] ans=matrix_product(matrix_power(A,c),b)[n-1][0] for i in range(n): ans-=a[i]**c print(ans)