#include <bits/stdc++.h>
int s[200010], m, n;
int main() {
  int i, t1 = 0, t2 = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &s[i]);
    if (s[i] == 0)
      t1++;
    else
      t2++;
  }
  for (i = 1; i <= n; i++) {
    if (s[i] == 0)
      t1--;
    else
      t2--;
    if (t1 == 0 || t2 == 0) {
      printf("%d\n", i);
      break;
    }
  }
  return 0;
}
