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