#include <bits/stdc++.h>
using namespace std;
long long a[200005];
int main() {
  int n;
  cin >> n;
  int one = 0, zero = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 1)
      one++;
    else if (a[i] == 0)
      zero++;
  }
  int count1 = 0, count2 = 0;
  for (int j = 0; j < n; j++) {
    if (a[j] == 0)
      count1++;
    else if (a[j] == 1)
      count2++;
    if (count1 == zero || count2 == one) {
      cout << j + 1 << endl;
      return 0;
    }
  }
  return 0;
}
