#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000000 + 7;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<long long> mario;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    mario.push_back(x);
  }
  sort(mario.rbegin(), mario.rend());
  long long update = 10e17;
  long long ans = 0;
  for (int i = 0; i < mario.size(); i++) {
    update = min(update - 1, mario[i]);
    ans += max(update, (long long)0);
  }
  cout << ans;
  return 0;
}
