input:sequence.in output:sequence.out

Time Limits: 1000 ms Memory Limits: 524288 KB

Description

Input

Output

Sample Input

1
2 5 4

Sample Output

1
29

Data Constraint