#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, n, m, *a, **c, *b, numl, numr, i;
  vector<long long> dor;
  cin >> n;
  a = new long long[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    dor.push_back(a[i]);
  }
  numl = count(dor.begin(), dor.end(), 0);
  numr = count(dor.begin(), dor.end(), 1);
  for (i = 0; i < n; i++) {
    if (a[i] == 0) {
      numl--;
    } else if (a[i] == 1) {
      numr--;
    }
    if (numr == 0 || numl == 0) {
      cout << i + 1 << "\n";
      break;
    }
  }
  return 0;
}
