#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, sum = 0;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n, greater<int>());
  long long ans = 0, flag = 0;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] != a[i + 1]) {
      flag = 1;
      break;
    }
  }
  if (flag == 0) {
    int m = a[0], cnt = 0;
    while (m != 0) {
      cnt += m;
      m--;
    }
    if ((n * (n - 1) / 2) >= sum)
      cout << max(1, cnt);
    else
      cout << sum - (n * (n - 1) / 2);
  } else {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (i != j) {
          if (a[j] == a[i]) {
            a[j]--;
          }
          if (a[j] == 0 || a[i] == 0) break;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      ans += a[i];
    }
    cout << ans;
  }
}
