#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#define ll long long
using namespace std;

int main()
{
    double n;
    cin >> n;
    double ave=0;
    vector<double> a(n);
    for (ll i =0; i < n;i++){
        cin >> a[i];
        ave += a[i];
    }
    ave /= n;
    //cout << ave << endl;
    ll ans = n - 1;
    for (ll i = n - 1; i >= 0; i--)
    {
        if(abs(a[ans]-ave)>=abs(a[i]-ave)){
            ans = i;
        }
    }
    cout << ans << endl;
}

#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;
}
