#include <bits/stdc++.h>
using namespace std;
int main(int argC, char** argV) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n;
  int a = 0, b = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> m;
    if (m)
      a = i;
    else
      b = i;
  }
  cout << min(a, b);
  return 0;
}
