#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
vector<int> vec;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  int cnt1 = 0;
  int cnt0 = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    vec.push_back(a);
    if (a)
      cnt1++;
    else
      cnt0++;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int p = vec[i];
    if (p)
      cnt1--;
    else
      cnt0--;
    if (!cnt1 || !cnt0) {
      ans = i + 1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
