#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[200001];
  for (int i = 1; i <= n; i++) cin >> a[i];
  int res = n;
  bool check = a[n];
  for (int i = n - 1; i > 0; i--) {
    if (!a[i] && check) {
      check = 0;
      res = i;
      break;
    }
    if (a[i] && !check) {
      check = 1;
      res = i;
      break;
    }
  }
  cout << res;
  return 0;
}
