#include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
  long long n, a[200005], l = 0, r = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0)
      l++;
    else
      r++;
  }
  if (n == r || l == n) {
    cout << n;
    return 0;
  }
  for (int i = n - 2; i >= 0; i--) {
    if (a[i] != a[n - 1]) {
      cout << i + 1;
      return 0;
    }
  }
  return 0;
}
