#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int ros;
    vector <int> a;
    a.resize(n);
    for (int i = 0; i < n - 1; i++)
    {
        cin >> a[i];
    }
    sort(a.rbegin(),a.rend());
    int count = 0;
    int ans = 0;
    int number = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        if (!(i == 0))
        {
            if (!a[i] == a[i - 1])
            {
                number = a[i] - count;
            }
        }
        
        ans = ans + number;
        count++;
    }
    
    
    cout << ans;
}