#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  bool one = false;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (i == n - 1 && arr[i] == 1) one = true;
  }
  for (int i = n - 1; i >= 0; i--) {
    if (one == true && arr[i] == 0) {
      cout << i + 1;
      return 0;
    }
    if (one == false && arr[i] == 1) {
      cout << i + 1;
      return 0;
    }
  }
  return 0;
}
