#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, left = 0, right = 0, ans1, ans2;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0)
      left++;
    else
      right++;
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      left--;
      if (left == 0) ans1 = i + 1;
    } else {
      right--;
      if (right == 0) ans2 = i + 1;
    }
  }
  cout << min(ans1, ans2);
  return 0;
}
