#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, rt = 0, lt = 0, c = 0;
  cin >> n;
  int ar[n];
  for (i = 0; i < n; ++i) {
    cin >> ar[i];
    if (ar[i] == 0)
      lt++;
    else
      rt++;
  }
  for (i = 0; i < n; ++i) {
    if (ar[i] == 0)
      lt--;
    else
      rt--;
    c++;
    if (lt == 0 || rt == 0) break;
  }
  cout << c << "\n";
  return 0;
}
