#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int s1 = 0, s2 = 0;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i])
      s1++;
    else
      s2++;
  }
  for (int i = 0; i < n; i++) {
    if (a[i])
      s1--;
    else
      s2--;
    if (s1 == 0 || s2 == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0;
}
