#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	int n;
	cin >> n;
    long long a[100001] = {0};
    int b;
    for (int i = 0; i < n; i++) {
        cin >> b;
        a[b] += 1;
    }
    int c = 100000;
    int s = 0;
    int i = 100000;
    while (c > 0) {
        s += a[i] * c;
        c -= a[i] + 1;
        i -= 1;
    }
    cout << s;
}
