#include <bits/stdc++.h>
#pragma gcc optimize("O3, unroll-loops")
using namespace std;
template <typename It>
ostream& outIt(ostream& out, It b, It e) {
  for (It i = b; i != e; i++) out << (i == b ? "" : " ") << *i;
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T>& v) {
  return outIt(out << '[', (v).begin(), (v).end()) << ']';
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> p) {
  return out << '(' << p.first << ", " << p.second << ')';
}
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& p) {
  return in >> p.first >> p.second;
}
int64_t invmod(int64_t a, int64_t b, int64_t mod, int64_t s0 = 0,
               int64_t s1 = 1) {
  return b ? invmod(b, a % b, mod,
                    (s1 - ((int64_t)a / b * s0) % mod + mod) % mod, s0)
           : s1;
}
int64_t mini = -1;
int64_t mins = INT_MAX;
inline void let(int64_t i, int64_t x) {
  if (x < mins) mins = x, mini = i;
}
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int64_t n;
  cin >> n;
  int64_t xax = invmod(7, n, n);
  for (int64_t i = 1; i <= n; i++) {
    int64_t x;
    cin >> x;
    if (n % 7 == 0) {
      if (i % 7) let(i, x - 1);
    } else {
      int64_t next = ((int64_t)xax * i * 7 - i) % (7 * n) / n;
      if (next >= x)
        let(i, x - 1);
      else
        x -= next + 1, let(i, x / 6 * 7 + x % 6 + 1 + next);
    }
  }
  cout << mini << endl;
}
