#include <bits/stdc++.h>
using namespace std;

vector<int> boxesWide;
vector<int> boxesLeftOne;
vector<int> boxesLeftTwo;
vector<int> boxesLeftThree;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int numberBoxes;
    long long boxesWideTotal=0;
    cin >> numberBoxes;

    for(int currentBox=1; currentBox<=numberBoxes; currentBox++)
    {
        int currentBoxWide;
        cin >> currentBoxWide;

        boxesWide.push_back(currentBoxWide);
        boxesLeftOne.push_back(currentBoxWide-1);
        boxesLeftTwo.push_back(currentBoxWide-1);
        boxesLeftThree.push_back(currentBoxWide-1);
        boxesWideTotal+=currentBoxWide;
    }

    sort(boxesWide.begin(), boxesWide.end());
    sort(boxesLeftOne.begin(), boxesLeftOne.end());
    sort(boxesLeftTwo.begin(), boxesLeftTwo.end());
    sort(boxesLeftThree.begin(), boxesLeftThree.end());


    for(int currentBox=boxesWide.size()-2; currentBox>=0; currentBox--)
    {
        for(int otherBox=currentBox+1; otherBox<boxesWide.size(); otherBox++)
        {
            if(boxesWide[currentBox]<=boxesLeftOne[otherBox])
            {
                boxesWideTotal-=boxesWide[currentBox];
                boxesLeftOne[otherBox]-=boxesWide[currentBox];
                break;
            }
            else if(boxesWide[currentBox]<=boxesLeftTwo[otherBox])
            {
                boxesWideTotal-=boxesWide[currentBox];
                boxesLeftTwo[otherBox]-=boxesWide[currentBox];
                break;
            }
            else if(boxesWide[currentBox]<=boxesLeftThree[otherBox])
            {
                boxesWideTotal-=boxesWide[currentBox];
                boxesLeftThree[otherBox]-=boxesWide[currentBox];
                break;
            }
        }
    }

    cout << boxesWideTotal;
    return 0;
}
