#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MAX = 10000005;
int main() {
  int n;
  cin >> n;
  vector<long long> nums;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    nums.push_back(a);
  }
  sort(nums.begin(), nums.end());
  long long ans = 0, curmax = 1999999999;
  for (int i = nums.size() - 1; i >= 0; --i) {
    curmax = min(nums[i], curmax - 1);
    if (curmax <= 0) break;
    ans += curmax;
  }
  cout << ans;
  return 0;
}
