#include <bits/stdc++.h>
using namespace std;
template <class T>
class Naikam {
 private:
  T n;

 public:
  Naikam(T n);
  T kam();
};
template <class T>
Naikam<T>::Naikam(T n) {
  this->n = n;
}
template <class T>
T Naikam<T>::kam() {
  T i, p, x;
  vector<T> a;
  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;
    }
  }
  return p;
}
int main() {
  long long int n;
  cin >> n;
  Naikam<long long int> hahaha(n);
  cout << hahaha.kam() << endl;
  return 0;
}
