#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main() {
  int cnt0 = 0, cnt1 = 0;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i])
      cnt1++;
    else
      cnt0++;
  }
  int t1 = 0, t2 = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i])
      t1++;
    else
      t2++;
    if (cnt1 == t1 || cnt0 == t2) {
      printf("%d\n", i);
      return 0;
    }
  }
  return 0;
}
