#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long p, q;
  for (long long i = n - 1; i >= 0; i--) {
    if (a[i] == 0) {
      p = i;
      break;
    }
  }
  for (long long i = n - 1; i >= 0; i--) {
    if (a[i] == 1) {
      q = i;
      break;
    }
  }
  cout << min(p, q) + 1;
  return 0;
}
