#include <bits/stdc++.h>
using namespace std;
void rec(int y, int x, int n, int a[]) {
  int i = y, j = x, c = a[(x + y) / 2], s;
  while (i <= j) {
    for (i; a[i] > c; i++)
      ;
    for (j; a[j] < c; j--)
      ;
    if (i <= j) {
      s = a[i];
      a[i] = a[j];
      a[j] = s;
      j--;
      i++;
    }
  }
  if (j > y) rec(y, j, n, a);
  if (i < x) rec(i, x, n, a);
}
int main() {
  int n;
  cin >> n;
  int x[n];
  for (int i = 0; i < n; i++) cin >> x[i];
  rec(0, n - 1, n, x);
  long long max = x[0];
  for (int i = 1; i < n; i++) {
    if (x[i - 1] > x[i])
      max += x[i];
    else {
      x[i] = x[i - 1] - 1;
      if (x[i] > 0) max += x[i];
    }
  }
  cout << max;
}
