#include <bits/stdc++.h>
using namespace std;
long long int a[300000];
int main() {
  long long int mn, count = 0, count2 = 0, n, j, i, k, b, c;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    ++count;
    if (a[i] == 0)
      b = i;
    else if (a[i] == 1)
      c = i;
  }
  mn = min(b, c);
  cout << mn << endl;
  return 0;
}
