/*
* * author: attacker
* * created: 03.04.2026 17:56:32
*/
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 1
#endif
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define bpc __builtin_popcount
#define size(v) (int)(v.size())
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
cout << count(a.begin(), a.end(), 1) << ' ' << count(a.begin(), a.end(), 2) << '\n';
int city = 0, opp = 0;
int cc = 1;
for (int i = 0; i < n; i++) {
if (a[i] == 1) city += 1;
else opp += 1;
if (city == opp) cc += 1;
}
cout << cc << '\n';
vector<pair<int, int>> seg;
seg.push_back({a[0], 1});
for (int i = 1; i < n; i++) {
auto& [x, y] = seg.back();
if (x == a[i]) {
y += 1;
} else {
seg.push_back({a[i], 1});
}
}
city = 0, opp = 0;
int mx = (int) -1e9;
for (auto [x, y] : seg) {
int new_city = city, new_opp = opp;
if (x == 1) {
new_city += y;
} else {
new_opp += y;
}
if (city < opp && new_city > new_opp) {
mx = max(mx, y);
} else if (city > opp && new_city < new_opp) {
mx = max(mx, y);
}
city = new_city, opp = new_opp;
}
cout << mx << '\n';
return 0;
}