//ignore header files
int main(int argc, char const* argv[])
{
int x;
while(scanf("%d",&x) != EOF){
string line;
getline(cin,line);
getline(cin,line);
istringstream stream(line);
int an;
int n = 0;
int sum = 0;
while(stream>>an){
n++;
}
n--;
istringstream s2(line);
while(n>0){
s2>>an;
sum = sum*x;
sum = sum+n*an;
n--;
}
printf("%d\n",sum);
}
return 0;
}