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

void executeTime() {
    cerr << "Time Taken: " << (float)clock() / CLOCKS_PER_SEC << " secs";
}

int main() {

    int n; cin >> n;

    vector<int> v(n);
    for (auto &x : v) {
        cin >> x;
    }

    map<int, int> mp;

    for (auto &x : v) {
        mp[x] ++;
    }

    int ans = 0;

    int ls = 0;
    for (auto it = mp.rbegin(); it != mp.rend(); it++) {

        it->second += ls;
        ls = it->second;

        ans += it->second;
    }

    ans -= mp.begin() -> second;

    cout << ans << endl;

    executeTime();
    return 0;
}