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