#include <bits/stdc++.h>
using namespace std;
const int inf = (int)2e9;
const long long md = 1000000007;
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  ;
  int r = accumulate((v).begin(), (v).end(), 0);
  int l = n - r;
  int ans;
  for (int i = 0; i < (int)n; i++) {
    if (v[i])
      r--;
    else
      l--;
    if (l == 0 || r == 0) {
      ans = i;
      break;
    }
  }
  cout << ans + 1 << "\n";
}
