#include <bits/stdc++.h>
using namespace std;
long long a[200002], n, res, l, r;
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i], res += a[i];
  for (long long i = 1; i <= n; i++) {
    if (a[i] == 1)
      r++;
    else
      l++;
    if (r == res || l == (n - res)) return cout << i, 0;
  }
}
