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

int deliting(int num, vector<int> &a){
    int mnoj = 0;
    int x = a[num];
    for(int i = a.size() - 1; i >= 0; i--){
        if (a[i] == x){
            a[i] = 1;
            mnoj++;
        }
        if (a[i] < x && a[i] != 1)
            a[i] -= mnoj;
        if (a[i] > x)
            a[i] += mnoj;
    }
    return mnoj;
}

int main() {
    int n;
	cin >> n;
    vector <int> a;
    int g, cnt = 0;
    for (int i = 0; i < n; i++){
        cin >> g;
        a.push_back(g);
    }
    sort(a.begin(), a.end());
    while (a[a.size() - 1] != 1){
        int p = a[a.size() - 1];
        int mnoj = deliting(a.size() - 1, a);
        cnt += p * mnoj;
        sort(a.begin(), a.end());
    }
    cout << cnt;
}