#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a[200003], c1 = 0, c2 = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i])
      c1++;
    else
      c2++;
  }
  for (int i = 0; i < n; i++) {
    if (!c1 || !c2) return cout << i, 0;
    if (a[i])
      c1--;
    else
      c2--;
  }
}
