#include <bits/stdc++.h>
using namespace std;
int main() {
  int count1 = 0, count2 = 0, n;
  cin >> n;
  int k = 0;
  int a[n];
  for (int l = 0; l < n; l++) cin >> a[l];
  for (int i = 0; i < n; i++) {
    if (a[i] == 1)
      count1++;
    else
      count2++;
  }
  for (int j = 0; j < n; j++) {
    if (a[j] == 0) {
      count2--;
      k++;
      if (count2 == 0) break;
    }
    if (a[j] == 1) {
      count1--;
      k++;
      if (count1 == 0) break;
    }
  }
  std::cout << k;
}
