#include <bits/stdc++.h>
const int oo = 0x7fffffff;
const long long OO = 0x7fffffffffffffff;
std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> ind(n);
  for (auto &x : ind) cin >> x;
  int ct[2] = {0, 0}, CT[2] = {0, 0};
  for (int i = 0; i < 2; ++i) CT[i] = count(ind.begin(), ind.end(), i);
  for (int i = 0; i < n; ++i) {
    ct[ind[i]]++;
    for (int c = 0; c < 2; ++c)
      if (ct[c] == CT[c]) {
        cout << (i + 1) << endl;
        return 0;
      }
  }
  return 0;
}
