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