Two countries, Country A and Country B, are at war. As a soldier in Country A, you will lead n soldiers to occupy the territory of Country B.

The territory of Country B is represented by a two-dimensional grid. The first place you occupy is a square on the 2D grid. Each of the soldiers you lead has h_i health. Each soldier can spend 1 health to move. Assuming that the current cell is (a, b), the movement destination is the four directions (a + 1, b), (a-1, b), (a, b + 1), (a, b-1). It is possible to choose. Soldiers will not be able to move from there when their health reaches zero. Any square passed by one or more soldiers can be occupied.

Your job is to find out how many squares you can occupy at most.
However, the size of this two-dimensional grid should be infinitely wide.



Input

The input is given in the following format.


n
h1
..
..
..
hn


Input meets the following constraints
1 ≤ n ≤ 500
1 ≤ hi ≤ 10,000,000

Output

Output the answer value on one line

Examples

Input

2
5
5


Output

11


Input

10
10
10
10
10
10
10
10
10
10
10


Output

93


Input

5
1
2
3
4
5


Output

15
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int deg=1;

    int ans=1;

    int n;cin>>n;
    vector<int>h(n);
    for(int i=0;i<n;i++)cin>>h[i];

    while(true){
        int cnt=0;
        for(int i=0;i<h.size();i++){
            if(h[i]!=0)cnt++;
        }
        if(cnt<=deg*4)break;
        ans+=deg*4;
        for(int i=0;i<h.size();i++)h[i]=max(0ll,h[i]-1);
        deg++;
    }

    for(int i=0;i<h.size();i++)ans+=h[i];

    cout<<ans<<endl;
    return 0;
}