#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; cnt = 0; } else { cnt++; } } print(cnt, ans); ans += cnt * (cnt + 1) / 2; ll ans2 = N * (N+1) / 2 - ans; print(ans2); return 0; }