//
//  Created by Ruslan Jankurazov.
//  Copyright © 2018 Ruslan Jankurazov. All rights reserved.
//

#pragma GCC optimize("Ofast")

#include "bits/stdc++.h"

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define f first
#define s second
#define uint unsigned int
#define pii pair <int, int>
#define pll pair <ll, ll>

using namespace std;

int a[100500];
int cnt[100500];


int main() {
#define FILE_INPUT 0
#define FILE ""
#ifndef DEBUG
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#if FILE_INPUT == 1
#warning "FREOPEN is on"
    freopen(FILE".in", "r", stdin);
    freopen(FILE".out", "w", stdout);
#endif
#endif
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    int q = -1, e = -1;
    for (int i = 1; i <= 1e5; ++i) {
        if (cnt[i] == q) {
            e = q;
            q = cnt[i];
        }
        if (cnt[i] > q) {
            e = q;
            q = cnt[i];
        }
    }
    if (e == -1) {
        cout << n/2;
    } else
        cout << n - q - e;
    return 0;
}
