eb1c64b14b95ef71dac00cd1d2252dfef8bf371e93025b12d82220512184f93d
// https://szkopul.edu.pl/problemset/problem/ZLG7FB_afACLMh8-zsupw5zV/site/?key=statement
// OIG V (1 etap)
#include <iostream>
#include <limits.h>
using namespace std;
const int sizik = 1000 * 1000 + 17;
int arr[sizik];
int arr2[sizik];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
std::cin >> n;
int jpr = 0, zlw = 0;
for (int i = 0; i < n; i++) {
std::cin >> arr[i];
if (arr[i] == 1) {
jpr++;
}
}
if (n == 1) {
cout << "0\n";
return 0;
}
int ans = INT_MAX;
for (int i = 0; i <= n; i++) {
ans = min(ans, jpr + zlw);
if (arr[i] == 1) {
jpr--;
} else {
zlw++;
}
}
cout << ans << '\n';
return 0;
}