NATALIAP - Natalia Got A Problem

Natalia is a very bright Computing Science freshmen in PUCMM at Santiago de los Caballeros. She is now taking the introductory math course and is learning about series. She finds the topic pretty cool.

This week, her teacher presented a new type of series called the "Argentinian Series". For bases Ai and exponents Ki, an Argentinian Series has the following form:

Argentinian Series

Natalia thinks it is too much work to evaluate an Argentinian Series so she wants you to write a computer program than can help her out. Would you be so kind as to serve her needs?

Input

The input contains a first line with an integer N (1 ≤ N ≤ 10), the value of the highest exponent in the series.

Then there's a line with N space separated integers (1 ≤ Ai ≤ 9). Each of these integers represent the i-th coefficient of the given Argentinian Series. Please note that the coefficients are arranged so that the first one has the highest exponent (N), and so on.

Output

Please output a 32-bit integer representing the evaluation of the series.

Example

Input:
3
2 4 6
4
5 5 4 6

Output:
6
93

Added by:kojak_
Date:2012-09-18
Time limit:0.100s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C CSHARP C++ 4.3.2 CPP JAVA
Resource:Roberto Abreu's Repository

hide comments
2013-07-19 23:31:44 Mitch Schwartz
This isn't an algorithmic problem, it's just plugging numbers into a formula. Moved to tutorial.

Last edit: 2013-07-19 23:36:08
2013-07-19 16:49:59 BLANKRK
too ezy.... :D
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.