#include <bits/stdc++.h>
int main() {
  int n, m = 0, k, a[200009], min, max;
  scanf("%d", &n);
  for (k = 1; k <= n; k++) {
    scanf("%d", &a[k]);
    if (a[k] == 1)
      max = k;
    else
      min = k;
  }
  printf("%d\n", max > min ? min : max);
}
