#include <bits/stdc++.h>
using namespace std;
int n;
int x = 0;
int y = 0;
int a[1000005];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i])
      x++;
    else
      y++;
  }
  for (int i = 0; i < n; i++) {
    if (a[i])
      x--;
    else
      y--;
    if (!x || !y) {
      cout << i + 1 << endl;
      return 0;
    }
  }
}
