#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, cnt[2], cnt1[2], Max;
  ;
  long long a[200000];
  cnt[1] = 0;
  cnt[0] = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  cnt1[0] = cnt[0];
  cnt1[1] = cnt[1];
  for (int i = 1; i <= n; ++i) {
    cnt[a[i]]--;
    if (cnt[a[i]] == 0) {
      Max = i;
      break;
    }
  }
  cout << Max;
  return 0;
}
