#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline int chkmin(T &x, const T &y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
inline int chkmax(T &x, const T &y) {
  return x < y ? x = y, 1 : 0;
}
template <typename T>
inline T read(T &f) {
  f = 0;
  int x = 1;
  char c = getchar();
  while (!isdigit(c)) x = c == '-' ? -1 : 1, c = getchar();
  while (isdigit(c)) (f *= 10) += c & 15, c = getchar();
  return f *= x;
}
using int64 = long long;
using uint64 = unsigned long long;
const int N = 200000 + 5;
int n, A[N];
int main() {
  read(n);
  for (int i = (1), ___ = (n); i <= ___; ++i) read(A[i]);
  int c0 = 0, c1 = 0;
  for (int i = (1), ___ = (n); i <= ___; ++i) {
    if (A[i] == 0) chkmax(c0, i);
    if (A[i] == 1) chkmax(c1, i);
  }
  printf("%d\n", min(c0, c1));
  return 0;
}
