#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, ans = 0;
  cin >> n;
  int z = 0, o = 0;
  int ark[n];
  for (int i = 0; i < n; i++) cin >> ark[i], (ark[i] == 0) ? z++ : o++;
  int j = 0;
  while (z && o) {
    (ark[j++] == 0) ? z-- : o--;
    ans++;
  }
  cout << ans;
  return 0;
}
