#include <bits/stdc++.h>
using namespace std;
map<long long, long long> mp;
string s;
long long n, m, k, ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(0));
  cin >> n;
  vector<long long> a(n + 1, 0);
  for (long long i = 1; i <= n; ++i) cin >> a[i];
  for (long long i = n; i >= 1; --i)
    if (a[i] && !m)
      m = i;
    else if (!a[i] && !k)
      k = i;
  cout << min(m, k);
}
