#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int ave;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += a[i];
  }
  ave = sum / N;
  int A = -1;
  for (int dif = 0; dif < 100; dif++) {
    for (int i = 0; i < N; i++) {
      int sub1 = a[i] - ave;
      int sub2 = ave - a[i];
      if ((sub1 == dif) || (sub2 == dif)) {
        A = i;
        break;
      }
    }
    if (A >= 0) {
      break;
    }
  }
  cout << A << endl;
}
