import std.stdio;alias L=long;L M=998244353,n,z,r;L[]U;L[L]R;void main(){readf("%d\n",&n);foreach(c;readln[0..n])U~=c-'0';L h(L m){L f;foreach(u;U[0..m])f=f*2%M+u;foreach(i,u;U)if(i/m&1^U[i%m]^u)return f+u;return f+1;}foreach(m;1..n+1)if(n%m<n/m%2){r=h(m);foreach(l,q;R)r+=m%l?0:M-q;z+=r*m*2%M;R[m]=r%M;}writeln(z%M);}