#include <bits/stdc++.h>
using namespace std;
int indexoflast(int a[], int b, int n) {
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == b) return i + 1;
  }
}
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int one = indexoflast(a, 1, n);
  int zer0 = indexoflast(a, 0, n);
  one < zer0 ? cout << one : cout << zer0;
}
