#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int temp, ct = INT_MAX;
  long long sum = 0;
  priority_queue<int> pq;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    pq.push(temp);
  }
  while (!pq.empty() && ct > 0) {
    if (pq.top() > ct) {
      sum += ct;
      ct--;
      pq.pop();
    } else if (pq.top() <= ct) {
      sum += pq.top();
      ct = pq.top() - 1;
      pq.pop();
    }
  }
  cout << sum << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  while (T--) {
    solve();
  }
}
