1.
/**
* Angewandte Mathematik, SS11
* Problem: 10268 - 498'
* Link: http://uva.onlinejudge.org/external/102/10268.html
*
* @author Fabian Trampusch
* @author Robert Schwarz
* @version 1.0, 29.05.2011
*
* Method : Ableitung, Hornerschema.
* Status : Accepted!
* Runtime: 0.456
*/

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
public static void main(String args[]) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);

long valueForX = 0;
long[] polynom = null;
long[] derivedPolynom = null;

while (true) {

try {
valueForX = Long.parseLong(br.readLine());
} catch (NumberFormatException e) {
System.exit(0);
}
polynom = readLongArr(br.readLine());
derivedPolynom = derivePolynom(polynom);

System.out.println(hornerScheme(derivedPolynom, valueForX));
}
}

public static long[] derivePolynom(long[] arr) {
if (arr.length > 1) {
long[] result = new long[arr.length - 1];

for (int i = 0; i < arr.length - 1; i++) {
result[i] = arr[i] * (arr.length - i - 1);
}

return result;
} else {
return new long[] { 0 };
}
}

public static long[] readLongArr(String line) {
StringTokenizer st = new StringTokenizer(line);

int countElements = st.countTokens();
long[] readLongs = new long[countElements];

for (int i = 0; i < countElements; i++) {
readLongs[i] = Integer.parseInt(st.nextToken());
}

return readLongs;
}

public static long hornerScheme(long[] polynom, long valueForX) {
long adder = 0;
long result = 0;

for (int i = 0; i < polynom.length; i++) {
result = polynom[i] + adder;
adder = result * valueForX;
}

return result;
}
}