#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int r = 0;
  int l = 0;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      r++;
    } else {
      l++;
    }
  }
  int m = 0;
  for (int i = 0; i < n; i++) {
    if (l == 0) {
      cout << m << endl;
      break;
    }
    if (r == 0) {
      cout << m << endl;
      break;
    }
    if (a[i] == 0) {
      r--;
      m++;
    } else {
      l--;
      m++;
    }
  }
}
