#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        auto low = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        auto up = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        ans += low * up;
    }
    cout << ans;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    double average = (double)accumulate(a.begin(), a.end(), 0)/n;
    int ans = 0;
    double minv=100100100;
    rep(i, n) {
        if (abs(average-(double)a[i])< minv) {
            ans = i;
            minv = abs(average-(double)a[i]);
        }
    }
    cout << ans << endl;
    //cout << a[ans] << endl;
}
