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

int main(){
    int_fast64_t N;
    scanf("%lld", &N);
    int_fast64_t M(0);
    vector<pair<int_fast64_t, int_fast64_t>> a(N);
    for(int_fast64_t i = 0; i < N; ++i){
        scanf("%lld", &a[i].first);
        M += a[i].first;
        a[i].first *= N;
        a[i].second = i;
    }
    sort(a.begin(), a.end());
    auto t = lower_bound(a.begin(), a.end(), make_pair(M, 0LL));
    auto s = lower_bound(a.begin(), a.end(), make_pair(lower_bound(a.rbegin(), a.rend(), make_pair(M, N), [](auto a, auto b){return a > b;}) -> first, 0LL));
    printf("%lld\n", ((t -> first + s -> first > 2 * M || ((t -> first + s -> first == 2 * M) && (t -> second > s -> second))) ? s -> second : t -> second));
    return 0;
}
