#include "iostream"
#include<stdio.h>
using namespace std;
int main()
{
unsigned int i,n,o,c,dep,pos_d,pos_m,last_pos,max, act;
//char* arr,*rn;
//cin>>n;
scanf( "%d", &n );
//fflush(stdin);
//arr = new char[2*n];
//arr = new char[2*n + 10]; // +10 just in case
//rn = fgets(arr, (2*n), stdin);
//scanf( "%s", &arr );
c=o=dep=pos_d=pos_m=last_pos=max=0;
for(i=0; i < n; i++)
{
//if(arr[i]==' ')
// continue;
scanf( "%d", &act );
if(act==1)
{
o++;
if(c>0)
c--;
else
{
dep++;
pos_d = (i/2)+1;
}
}
else if(act==2)
{
c++;
if(o>0)
o--;
if(o==0)
{
if(((i-last_pos+2)/2)>max)
{
max=(i-last_pos+2)/2;
pos_m = 1+(last_pos+1)/2;
}
last_pos = i+1;
}
}
}
cout<<dep<<" "<<pos_d<<" "<<max<<" "<<pos_m;
return 0;
}
I2luY2x1ZGUgImlvc3RyZWFtIgojaW5jbHVkZTxzdGRpby5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKQp7CiAgICB1bnNpZ25lZCBpbnQgaSxuLG8sYyxkZXAscG9zX2QscG9zX20sbGFzdF9wb3MsbWF4LCBhY3Q7CgkvL2NoYXIqIGFyciwqcm47CgkvL2Npbj4+bjsKCXNjYW5mKCAiJWQiLCAmbiApOwoJLy9mZmx1c2goc3RkaW4pOwoJLy9hcnIgPSBuZXcgY2hhclsyKm5dOwoJLy9hcnIgPSBuZXcgY2hhclsyKm4gKyAxMF07IC8vICsxMCBqdXN0IGluIGNhc2UKCS8vcm4gPSBmZ2V0cyhhcnIsICgyKm4pLCBzdGRpbik7CgkvL3NjYW5mKCAiJXMiLCAmYXJyICk7CgljPW89ZGVwPXBvc19kPXBvc19tPWxhc3RfcG9zPW1heD0wOwoJZm9yKGk9MDsgaSA8IG47IGkrKykKCXsKCQkvL2lmKGFycltpXT09JyAnKQoJCS8vCWNvbnRpbnVlOwoJCXNjYW5mKCAiJWQiLCAmYWN0ICk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