/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AThumbnail {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    in >> n;
	    double sum = 0.0;
	    vector<int> a(n);
	    for(int i=0; i<n; i++){
	        in >> a[i];
	        sum += (double)a[i];
	    }

	    double ave = sum / (double)n;

	    int res = 0;
	    double mi = inf;
	    for(int i=0; i<n; i++){
            double diff = abs(ave - (double)a[i]);
            if(diff < mi){
                mi = diff;
                res = i;
            }
	    }

	    out << res << endl;
	}
};


int main() {
	AThumbnail solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n;
  cin >> n;
  vector<vll> a(n, vll(2));
  long double avg = 0;
  for (ll i = 0; i < n; i++) {
    cin >> a[i][0];
    avg += a[i][0];
    a[i][1] = i;
  }
  avg /= n;
  ll m = -1;
  sort(all(a));
  for (ll i = 0; i < n; i++) {
    if (a[i][0] == avg) {
      cout << a[i][1] << endl;
      return 0;
    }
    if (a[i][0] > avg) {
      while (i > 0 && a[i][0] == a[i - 1][0]) i--;
      m = i;
      break;
    }
  }
  if (m == 0) {
    cout << a[m][1] << endl;
    return 0;
  }
  ll x = m - 1;
  while (x > 0 && a[x][0] == a[x - 1][0]) x--;
  //cout << a[m][0] - avg << " " << avg - a[x][0] << endl;
  if (a[m][0] - avg > avg - a[x][0]) cout << a[x][1] << endl;
  else if (a[m][0] - avg < avg - a[x][0]) cout << a[m][1] << endl;
  else {
    cout << min(a[x][1], a[m][1]) << endl;
  }
}