11605 - Polynomial Calculator   

Description

You are given a polynomial f(x). deg(f(x)) = N.
Given a integer M, please output the answer of f(M).

Sample Output Explanation : in sample input, the equation is x3 - x + 3, When M = 2, f(M) = 9

Input

The first line contains two integer numbers N, M, representing the degree of f(x) and the input number.
The second line contains N+1 integer numbers an, ... , a1a0, representing the coefficient of xn, xn-1, ... , x2, x1, x0.

  • 1 ≤ N ≤ 100
  • -1000 ≤ M, ai ≤ 1000
  • -109 ≤ f(M) ≤ 109

Output

Please output the answer of ​f(M)

Remember to print '\n' after your answer.

Sample Input  Download

Sample Output  Download

Tags




Discuss