#include <bits/stdc++.h>
using namespace std;
int main() {
  long long num;
  scanf("%lld", &num);
  long long arr[num];
  long long zero = 0, one = 0;
  for (long long i = 0; i < num; i++) {
    scanf("%lld", &arr[i]);
    if (arr[i] == 0)
      zero++;
    else
      one++;
  }
  long long cnt0 = 0, cnt1 = 0;
  for (long long i = 0; i < num; i++) {
    if (arr[i] == 1)
      cnt1++;
    else
      cnt0++;
    if (zero == cnt0 || one == cnt1) {
      return cout << i + 1 << endl, 0;
    }
  }
  return 0;
}
