#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
map<long long, long long> m;
long long a[200010];
int main() {
  long long t, n, i, j, k, l, mn = 0, mx = 0, one = 0, z = 0, oo = 0, zz = 0;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    if (a[i] == 1) one++;
  }
  z = n - one;
  for (int i = 0; i < n; i++) {
    if (a[i] == 1)
      oo++;
    else
      zz++;
    if (oo == one || zz == z) {
      cout << i + 1 << "\n";
      return 0;
    }
  }
}
