Prateek the BOT KILLER

0

0 votes
Easy
Problem

Many of you have played PUBG(relax! question is not specifically about PUBG). We have a player of PUBG with us Prateek usually, other players call Prateek as "BOT KILLER" and he gets annoyed by this so he decided to win the next game of PUBG. Prateek managed to survive till the end and lost his all ammunition and just one player(COSMIC) is left who is having far better RP then Prateek(good player then Prateek). Luckily COSMIC's ammunition is also over except one grenade(multiple explosion grenade). COSMIC has seen Prateek and opens voice chatting and ask Prateek if he will able to save himself from the grenade then COSMIC will surrender himself. help Prateek to solve the riddle. The behavior of the grenade is described with a recursion depth n and a duration for each level of recursion t1, t2, ..., tn. Once COSMIC launches the grenade in some cell(assume both are in a grid), the grenade starts moving upward. After covering t1cells (including the starting cell), it explodes and splits into two parts, each moving in the direction changed by 45 degrees (see the pictures below for clarification). So, one part moves in the top-left direction, while the other one moves in the top-right direction. Each part explodes again after covering t2 cells, splitting into two parts moving in directions again changed by 45 degrees. The process continues till the n-th level of recursion when all 2n - 1 existing parts explode and disappear without creating new parts. After a few levels of recursion, it's possible that some parts will be at the same place and at the same time — it is allowed and such parts do not crash.

Before launching a grenade, Prateek must make sure that he doesn't stand in cells which will be visited at least once by the grenade. Prateek has to tell the count of those cells.

Input

The first line will be n and the second line will be n-space separated numbers

Output

Print one integer, denoting the number of cells which will be visited at least once by any part of the Grenade.

Constraints

1 ≤ n ≤ 30

1 ≤ ti ≤ 5  

Time Limit: 2.5
Memory Limit: 256
Source Limit:
Explanation

 COSMIC launched the firework from the bottom-most red cell. It covered t1 = 4 cells (marked red), exploded and divided into two parts (their further movement is marked green). let denote different colors for next set of explosions, there are 4 red, 4 green, 8 orange, and 23 pink cells. So, the total number of visited cells is 4 + 4 + 8 + 23 = 39.

Editor Image

?