#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a = 0, b = 0, ans, x;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i] == 0) {
      x = i + 1;
      a = max(a, x);
    } else if (arr[i] == 1) {
      x = i + 1;
      b = max(b, x);
    }
  }
  ans = min(a, b);
  cout << ans;
}
