#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k0 = 0, k1 = 0, kol = 0;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    if (x[i] == 0) k0++;
    if (x[i] == 1) k1++;
  }
  for (int i = 0; i < n; i++) {
    if (x[i] == 0) {
      k0--;
      kol++;
    }
    if (x[i] == 1) {
      k1--;
      kol++;
    }
    if (k0 == 0 || k1 == 0) {
      cout << kol << endl;
      return 0;
    }
  }
  return 0;
}
