#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main() {
	int n;
	multiset<int> s;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int a;
		cin >> a;
		s.insert(a);
	}
	int sum = 0, border=0, prev = 0;
	while (s.size()!=0) {
		if (prev == *s.end()) {
			sum += *s.end();
		}
		else
		{
			sum += *s.end()-border;
		}
		prev = *s.end();
		border++;
		if (border >= *s.begin()) {
			int a = *s.begin();
			s.erase(a);
		}
	}
	cout << sum;
}
