#include <bits/stdc++.h>
using namespace std;
template <typename T>
void show(T &v) {
  for (long long &x : v) cout << x << " ";
  cout << endl;
}
template <typename T>
void ext(T a) {
  cout << a;
  std::exit(0);
}
const long long e9 = (long long)1e9;
const long long e6 = (long long)1e6;
const long long e5 = (long long)1e5;
signed main() {
  ios_base::sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long &i : v) cin >> i;
  long long a, b;
  a = b = 0;
  for (long long &i : v) {
    if (i == 1)
      a++;
    else
      b++;
  }
  long long ca = 0, cb = 0;
  long long ans = -1;
  for (long long i = 0; i < n; i++) {
    if (v[i] == 0) {
      cb++;
    } else {
      ca++;
    }
    if (ca == a || cb == b) {
      ans = i + 1;
      break;
    }
  }
  cout << ans;
  return 0;
}
