#include <bits/stdc++.h>
using namespace std;
bool isPrime(int num) {
  if (num == 1) return false;
  for (int i = 2; i <= sqrt(num); i++) {
    if (num % i == 0) return false;
  }
  return true;
}
int main() {
  int n, left = 0, right = 0;
  cin >> n;
  int a[n];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0)
      left++;
    else
      right++;
  }
  for (long long int i = 0; i < n; i++) {
    if (a[i] == 0)
      left--;
    else
      right--;
    if (left == 0 || right == 0) {
      cout << i + 1;
      exit(0);
    }
  }
}
