#include <bits/stdc++.h>
template <typename T>
std::istream& operator>>(std::istream& input, std::vector<T>& v) {
  for (T& a : v) input >> a;
  return input;
}
void answer(unsigned long long v) { std::cout << v << '\n'; }
void solve(std::vector<int>& a) {
  const size_t n = a.size();
  std::sort(a.begin(), a.end(), std::greater<int>());
  for (size_t i = 1; i < n; ++i) a[i] = std::min(a[i], a[i - 1] - 1);
  unsigned long long k = 0;
  for (size_t i = 0; i < n && a[i] > 0; ++i) k += a[i];
  answer(k);
}
int main() {
  size_t n;
  std::cin >> n;
  std::vector<int> a(n);
  std::cin >> a;
  solve(a);
  return 0;
}
