#include <bits/stdc++.h>   using namespace std;   long long i, j, flag, c, k, x, z, n, m, a[300007];   int main() {     cin >> n;     long long lst0 = 0, lst1 = 1;     for (i = 0; i < n; i++) {       cin >> a[i];       if (a[i] == 0)         lst0 = i + 1;       else         lst1 = i + 1;     }     cout << min(lst0, lst1) << endl;     return 0;   }   