#include #include typedef long long ll; using namespace std; template void print(H head) { cout << head << endl; } template void print(H&& head, T&&... tail){ std::cout << head << " ", print(std::forward(tail)...); } int main() { ll N; cin >> N; std::vector va(N); for (auto& a : va) cin >> a; ll cnt = 0LL; ll ans = 0LL; for (ll i = 0; i < N; i++) { if (va[i] == 0) { ans += cnt * (cnt + 1) / 2; print(i, cnt, ans); cnt = 0; } else { cnt++; } } ans += cnt * (cnt + 1) / 2; ll ans2 = N * (N+1) / 2 - ans; print(ans2); return 0; }