498
while 1:
try:
x=int(input())
a=list(map(int,input().split()))
n=len(a)-1
ans=0
for i in range(n):
ans+=a[i]*(n-i)*x**(n-i-1)
print(ans)
except:
break
Odd Sum
T=input()
for t in range(int(T)):
a=int(input())
b=int(input())
sum=0
for i in range(a,b+1):
if i%2==1:
sum+=i
print('Case '+str(t+1)+': '+str(sum))