78c7e6d5ace0249a05205f4aee51ce9d8976cea5b777203ff09945c161a0d8ec
// https://szkopul.edu.pl/problemset/problem/3GXkVUEnWNZRn2C2VpX2uKmq/site/?key=statement
// author: SuitokuinTenmu
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAX_N = 1000000 + 5;
int N, a[MAX_N], sum[MAX_N];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> N;
for (int i = 1; i <= N; i++) {
cin >> a[i];
sum[i] = sum[i - 1] + a[i];
}
if (!a[1]) {
int p = -1;
for (int i = 2; i <= N; i++) {
if (a[i]) {
p = i;
break;
}
}
if (p < 0) {
cout << "0\n";
} else if (a[p] < 0) {
cout << "BRAK\n";
} else {
cout << (N - p + 1) - (sum[N] - sum[p - 1]) << '\n';
}
} else if (a[1] > 0) {
cout << N - sum[N] << '\n';
} else {
int ans = sum[N] + N;
for (int i = 2, j; i <= N; i = j) {
j = i + 1;
if (a[i] > 0) {
ans = min(ans, sum[i - 1] + i - 1 + (N - i + 1) - (sum[N] - sum[i - 1]));
} else if (!a[i]) {
for (; j <= N && !a[j]; j++)
;
if (j > N || a[j] > 0) {
int tmp = 0;
if (a[i - 1] > 0) i--, tmp++;
ans = min(ans, tmp + sum[i - 1] + i - 1 + (N - j + 1) - (sum[N] - sum[j - 1]));
}
}
}
cout << ans << '\n';
}
return 0;
}