#include <bits/stdc++.h>
using namespace std;
const long long SIZE = 1e5 * 2;
vector<long long> vec;
long long q, n, m, k;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  vec.resize(n);
  for (int i = 0; i < n; i++) cin >> vec[i];
  long long ans = -1, s1 = 0, s2 = 0;
  for (int i = vec.size() - 1; i >= 0; i--) {
    if (vec[i] == 0 && s1 == 0) {
      s1 = 1;
      ans = i;
    } else {
      if (vec[i] == 1 && s2 == 0) {
        s2 = 1;
        ans = i;
      }
    }
  }
  cout << ans + 1;
  return 0;
}
