#include <bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<y;i++)
#define rfr(i,x,y) for(int i=x;i>=y;i--)
#define int long long

using namespace std;

const int N=1e5;

void solve()
{
    int n;
    cin>>n;
    vector<int> mas(n);
    fr(i,0,n)
    {
      cin>>mas[i];
    }
    sort(mas.begin(),mas.end());
    int cnt = 0;
    int ans = 0;
    int fixed = 0;
    rfr(i,n-1,0)
    {
      if(i == n - 1 || mas[i] != mas[i + 1])
      {
        if(mas[i] - cnt <= 0)
        {
          break;
        }
        fixed = cnt;
      }
      ans += mas[i] - fixed;
      cnt += 1;
    }
    cout << ans << '\n';
}

signed main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int t=1;
  while(t--)solve();
}
