#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, d, zero(0), one(0), counter(0);
  vector<long long> v;
  cin >> n;
  for (size_t i = 0; i < n; ++i) {
    cin >> d;
    v.push_back(d);
    if (d & 1) {
      one++;
    } else {
      zero++;
    }
  }
  for (auto z : v) {
    counter++;
    if (z & 1) {
      one--;
    } else {
      zero--;
    }
    if (one == 0 || zero == 0) {
      break;
    }
  }
  cout << counter << endl;
}
void tsolve() {
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
