#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n + 1];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int l = 0;
  int r = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] == 0)
      l++;
    else
      r++;
  }
  int l1 = 0;
  int r1 = 0;
  int ans;
  for (int i = 0; i < n; i++) {
    if (arr[i] == 0 && l1 == l - 1) {
      ans = i + 1;
      break;
    } else if (arr[i] == 1 && r1 == r - 1) {
      ans = i + 1;
      break;
    } else if (arr[i] == 0)
      l1++;
    else
      r1++;
  }
  cout << ans << endl;
  return 0;
}
