#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> v;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  long long sol = 0ll;
  long long tart = 2000000000ll;
  for (int i = 0; i < n; i++) {
    tart = min(tart - 1ll, v[i]);
    if (tart > 0) sol += tart;
  }
  cout << sol << endl;
  return 0;
}
