#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int i, a[n + 5], j = 0, k = 0, o[n + 5], z[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      z[j] = i + 1;
      j++;
    } else {
      o[k] = i + 1;
      k++;
    }
  }
  cout << min(z[j - 1], o[k - 1]) << endl;
  return 0;
}
