#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
int n;
char a[200009];
struct A{
int l,r,d;
bool operator<(const A& rhs)const{
if(r-rhs.r)return r<rhs.r;
return d>rhs.d;
}
};
A b[100009];
int bl;
constexpr int II = 131072;
int I;
int ma[2*II];
int getma(int dep,int ql,int qr,int ll,int rr){
if(ql<=ll&&rr<=qr)return ma[dep];
if(qr<ll||rr<ql)return 0;
return max(
getma(dep*2,ql,qr,ll,(ll+rr)/2),
getma(dep*2+1,ql,qr,(ll+rr)/2+1,rr));
}
void updatema(int i,int d){
i+=I;
while(i>0&&ma[i]<d){
ma[i]=d;
i>>=1;
}
}
int main(){
int i,j,k;
scanf("%d",&n);
scanf("%s",a);
int res=0;
for(i=0;i<n;){
if(a[i]=='1'){
i++;
continue;
}
for(j=i;j<n;j++){
if(a[j]=='1')break;
}
int l,r,d;
d=(j-i);
l=(((j+1)&(-2))>>1)-d;
r=(i&(-2))>>1;
b[bl++]={l,r,d};
i=j;
}
n>>=1;
I=1;
while(I<=n)I<<=1;
//sort(b,b+bl);
for(k=0;k<bl;k++){
for(i=b[k].l;i<=b[k].r;i++){
j=min(n,i+b[k].d);
int si = max(0,i);
int dj = j-si;
int di = getma(1,0,si,0,I-1);
updatema(j,di+dj);
}
printf("%d : %d %d %d\n",k,b[k].l,b[k].r,b[k].d);
for(i=0;i<=n;i++){printf("%d ",ma[i+I]);}
printf("\n");
}
printf("%d\n",n-ma[1]);
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8YWxnb3JpdGhtPgojaW5jbHVkZTxxdWV1ZT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IG47CmNoYXIgYVsyMDAwMDldOwpzdHJ1Y3QgQXsKICAgIGludCBsLHIsZDsKICAgIGJvb2wgb3BlcmF0b3I8KGNvbnN0IEEmIHJocyljb25zdHsKICAgICAgICBpZihyLXJocy5yKXJldHVybiByPHJocy5yOwogICAgICAgIHJldHVybiBkPnJocy5kOwogICAgfQp9OwpBIGJbMTAwMDA5XTsKaW50IGJsOwoKY29uc3RleHByIGludCBJSSA9IDEzMTA3MjsKaW50IEk7CmludCBtYVsyKklJXTsKaW50IGdldG1hKGludCBkZXAsaW50IHFsLGludCBxcixpbnQgbGwsaW50IHJyKXsKICAgIGlmKHFsPD1sbCYmcnI8PXFyKXJldHVybiBtYVtkZXBdOwogICAgaWYocXI8bGx8fHJyPHFsKXJldHVybiAwOwogICAgcmV0dXJuIG1heCgKICAgICAgICBnZXRtYShkZXAqMixxbCxxcixsbCwobGwrcnIpLzIpLAogICAgICAgIGdldG1hKGRlcCoyKzEscWwscXIsKGxsK3JyKS8yKzEscnIpKTsKfQp2b2lkIHVwZGF0ZW1hKGludCBpLGludCBkKXsKICAgIGkrPUk7CiAgICB3aGlsZShpPjAmJm1hW2ldPGQpewogICAgICAgIG1hW2ldPWQ7CiAgICAgICAgaT4+PTE7CiAgICB9Cn0KaW50IG1haW4oKXsKICAgIGludCBpLGosazsKICAgIHNjYW5mKCIlZCIsJm4pOwogICAgc2NhbmYoIiVzIixhKTsKICAgIGludCByZXM9MDsKICAgIGZvcihpPTA7aTxuOyl7CiAgICAgICAgaWYoYVtpXT09JzEnKXsKICAgICAgICAgICAgaSsrOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgZm9yKGo9aTtqPG47aisrKXsKICAgICAgICAgICAgaWYoYVtqXT09JzEnKWJyZWFrOwogICAgICAgIH0KICAgICAgICBpbnQgbCxyLGQ7CiAgICAgICAgZD0oai1pKTsKICAgICAgICBsPSgoKGorMSkmKC0yKSk+PjEpLWQ7CiAgICAgICAgcj0oaSYoLTIpKT4+MTsKICAgICAgICBiW2JsKytdPXtsLHIsZH07CiAgICAgICAgaT1qOwogICAgfQogICAgbj4+PTE7CiAgICBJPTE7CiAgICB3aGlsZShJPD1uKUk8PD0xOwogICAgLy9zb3J0KGIsYitibCk7CiAgICBmb3Ioaz0wO2s8Ymw7aysrKXsKICAgICAgICBmb3IoaT1iW2tdLmw7aTw9YltrXS5yO2krKyl7CiAgICAgICAgICAgIGo9bWluKG4saStiW2tdLmQpOwppbnQgc2kgPSBtYXgoMCxpKTsKICAgICAgICAgICAgaW50IGRqID0gai1zaTsKICAgICAgICAgICAgaW50IGRpID0gZ2V0bWEoMSwwLHNpLDAsSS0xKTsKICAgICAgICAgICAgdXBkYXRlbWEoaixkaStkaik7CiAgICAgICAgfQogICAgICAgIHByaW50ZigiJWQgOiAlZCAlZCAlZFxuIixrLGJba10ubCxiW2tdLnIsYltrXS5kKTsKICAgICAgICBmb3IoaT0wO2k8PW47aSsrKXtwcmludGYoIiVkICIsbWFbaStJXSk7fQogICAgICAgIHByaW50ZigiXG4iKTsKICAgIH0KICAgIAogICAgcHJpbnRmKCIlZFxuIixuLW1hWzFdKTsKfQ==