#include <bits/stdc++.h>
using namespace std;
int n, a[200005];
int last1, last0;
int main() {
  scanf("%d", &n);
  ;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 0) {
      last0 = i + 1;
      break;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 1) {
      last1 = i + 1;
      break;
    }
  }
  cout << (min(last0, last1)) << endl;
}
