#include <bits/stdc++.h>
using namespace std;
long long int extgcd(long long int a, long long int b, long long int& x,
                     long long int& y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  } else {
    int g = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return g;
  }
}
long long int hcf(long long int a, long long int b) {
  if (b > a) return (hcf(b, a));
  if (a % b == 0) return b;
  return (hcf(b, a % b));
}
long long int modpow(long long int a, long long int b) {
  long long int res = 1;
  a %= 1000000007;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  long long int a[n + 1], mx_len = 0;
  for (int i = (int)1; i <= (int)n; ++i) cin >> a[i];
  for (int i = (int)1; i <= (int)n - 1; ++i) {
    for (int j = (int)1; j <= (int)n - i; ++j) {
      if (a[j] < a[j + 1]) swap(a[j], a[j + 1]);
    }
  }
  mx_len += a[1];
  for (int i = (int)2; i <= (int)n; ++i) {
    if (a[i] >= a[i - 1]) {
      a[i] = a[i - 1] - 1;
      if (a[i] < 0) a[i] = 0;
    }
    mx_len += a[i];
  }
  cout << mx_len << "\n";
  return 0;
}
