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