#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 7;
const long long INFL = 8e18L + 7;
const double INFD = 1e300;
void run();
int main() {
  if (strlen("") > 0) {
    freopen(
        ""
        ".in",
        "r", stdin);
    freopen(
        ""
        ".out",
        "w", stdout);
  }
  run();
  return 0;
}
const int N = 1e6 + 7;
int n;
long long a[N];
void run() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  reverse(a, a + n);
  for (int i = 1; i < n; i++) a[i] = max(0LL, min(a[i], a[i - 1] - 1));
  cout << accumulate(a, a + n, 0LL) << endl;
}
