#include <bits/stdc++.h>
using namespace std;
char CRTBUFF[30000];
struct debugger {
  static void call(const char* it) {}
  template <typename T, typename... aT>
  static void call(const char* it, T a, aT... rest) {
    string b;
    for (; *it && *it != ','; ++it)
      if (*it != ' ') b += *it;
    cerr << b << "=" << a << " ";
    call(++it, rest...);
  }
};
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  };
  int x, n;
  cin >> n;
  int a[n + 10], freq[3];
  for (int i = 0; i < n; i++) cin >> a[i];
  freq[0] = freq[1] = 0;
  for (int i = 0; i < n; i++) {
    freq[a[i]]++;
  }
  for (int i = 0; i < n; i++) {
    freq[a[i]]--;
    if (freq[a[i]] == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
}
