#include <bits/stdc++.h>
const long double PI = acos(-1.0);
const long long llINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
using namespace std;
const int maxn = 2e5 + 7, maxm = 1e5 + 7;
int N, M, K;
int data[maxn];
int main() {
  std::ios::sync_with_stdio(false);
  cin >> N;
  int a = N, b = N;
  for (int i = 0; i < N; ++i) cin >> data[i];
  while (data[--a] == 0)
    ;
  while (data[--b] == 1)
    ;
  cout << min(a, b) + 1;
  return 0;
}
