#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  vector<int> v;
  cin >> n;
  int c0 = 0, c1 = 0;
  for (int i = 0, x; i < n; i++) {
    cin >> x;
    v.push_back(x);
    if (v[i] == 0) c0++;
    if (v[i] == 1) c1++;
  }
  for (int i = 0; i < n; i++) {
    if (v[i] == 0) c0--;
    if (v[i] == 1) c1--;
    if (c0 == 0 || c1 == 0) {
      cout << i + 1 << "\n";
      return 0;
    }
  }
  return 0;
}
