#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  int zeroes = 0, ones = 0;
  int lastOne = (int)1e9 + 1, lastZero = (int)1e9 + 1;
  int d;
  for (int i = 0; i < N; ++i) {
    cin >> d;
    if (d == 1) {
      lastOne = i + 1;
    } else {
      lastZero = i + 1;
    }
  }
  int k = min(lastZero, lastOne);
  cout << k << "\n";
}
