#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
//const ll MOD=1000000007;
const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}


template<long long int mod=1000000007>
struct Mod_Int{
    typedef long long int ll;
    typedef pair<ll,ll> pll;
    typedef Mod_Int<mod> M;
    ll a;
    
    ll mod_pow(ll a,ll x){
        a%=mod;
        ll ans=1;
        for(int i=0;i<63;i++){
            if(x>>i&1){ans*=a; ans%=mod;}
            a*=a;
            a%=mod;
        }
        return ans;
    }
    
    pll Ex_gcd(ll a,ll b){
        if(b==0){return {1,0};}
        pll ret=Ex_gcd(b,a%b);
        ret.F-=a/b*ret.S;
        return {ret.S,ret.F};
    }
    
    ll prime_R(ll a){
        return mod_pow(a,mod-2);
    }
    
    ll R(ll a){
        ll ret=Ex_gcd(a,mod).F;
        ret%=mod;
        if(ret<0){ret+=mod;}
        return ret;
    }
    
    Mod_Int(ll A=0):a(A){
        a%=mod;
        if(a<0){a+=mod;}
    }
    
    Mod_Int(const M &b):a(b.a){}
    
    M & operator += (const M &b){
        a+=b.a;
        if(a>=mod){a-=mod;}
        return *this;
    }
    
    M operator + (const M &b) const {
        M c=*this;
        return c+=b;
    }
    
    M & operator -= (const M &b){
        a-=b.a;
        if(a<0){a+=mod;}
        return *this;
    }
    
    M operator - (const M &b) const {
        M c=*this;
        return c-=b;
    }
    
    M & operator *= (const M &b){
        (a*=b.a)%=mod;
        return *this;
    }
    
    M operator * (const M &b) const {
        M c=*this;
        return c*=b;
    }
    
    M & operator /= (const M &b){
        (a*=R(b.a))%=mod;
        return *this;
    }
    
    M operator / (const M &b) const {
        M c=*this;
        return c/=b;
    }
    
    M & mod_pow_equal(ll x){
        ll ans=1;
        while(x>0){
            if(x&1){ans*=a; ans%=mod;}
            a*=a;
            a%=mod;
            x>>=1;
        }
        a=ans;
        return *this;
    }
    
    M mod_pow(ll x){
        M c(a);
        return c.mod_pow_equal(x);
    }
    
    bool operator == (const M &b) const {return a==b.a;}
    
    bool operator != (const M &b) const {return a!=b.a;}
    
    bool operator <= (const M &b) const {return a<=b.a;}
    
    bool operator < (const M &b) const {return a<b.a;}
    
    bool operator > (const M &b) const {return a>b.a;}
    
    bool operator >= (const M &b) const {return a>=b.a;}
    
    M & operator = (const M &b){
        a=b.a;
        return *this;
    }
    
    M & operator = (const ll &b){
        (a=b)%=mod;
        if(a<0){a+=mod;}
        return *this;
    }
};

template<long long MOD>istream & operator >> (istream &i,Mod_Int<MOD> &A){ll a; cin>>a; A=Mod_Int<MOD>(a); return i;}
template<long long MOD>ostream & operator << (ostream &i,const Mod_Int<MOD> &A){i<<A.a; return i;}



ll cnt2(ll N,ll K){
  ll cnt=0;
  ll tmp=K;
  do{
    cnt++;
    if(tmp&1){tmp>>=1;}
    else{tmp>>=1; tmp^=(1LL<<(N-1));}
  }while(tmp!=K);
  return cnt;
}

typedef Mod_Int<MOD> Int;

bool comp(const string &s,const vector<int> &d){
  ll N=s.size();
  for(int i=0;i<N;i++){
    if(s[i]!=d[i]){return s[i]>d[i];}
  }
  return true;
}

int main(){
  ll N;
  string X;
  cin>>N>>X;
  reverse(X.begin(),X.end());
  for(auto &I:X){I-='0';}
  Int ans=0;
  for(int i=0;i<N;i++){
    if(X[i]){
      ans+=Int(2).mod_pow(i);
    }
  }
  ans+=1;
  ans*=N*2;
  reverse(X.begin(),X.end());
  const ll MX=1000000;
  vector<Int> CNT(MX,0);
  for(ll i=3;i<=N;i+=2){
    if(N%i==0){
      Int cnt=0;
      ll bl=N/i;
      for(int j=0;j<bl;j++){
        if(X[j]==1){cnt+=Int(2).mod_pow(bl-j-1);}
      }
      vector<int> D(N);
      for(int j=0;j<N;j++){
        if((j/bl)&1){
          D[j]=X[j%bl]?0:1;
        }
        else{
          D[j]=X[j%bl];
        }
      }
      if(comp(X,D)){cnt+=1;}
      CNT[bl]=cnt;
    }
  }
  
  auto valid=[&](ll a){return N%a==0 && ((N/a)&1)==1 && a!=N;};

  for(ll i=1;i<=N;i++){
    if(!valid(i)){continue;}
    for(ll j=2;i*j<=N;j++){
      if(valid(i*j)){CNT[i*j]-=CNT[i];}
    }
  }
  
  for(ll i=1;i<=N;i++){
    if(!valid(i)){continue;}
    Int cnt=CNT[i];
    ll bl=i;
    //cout<<bl<<" "<<cnt<<endl;
    ans-=cnt*N*2;
    ans+=cnt*bl*2;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 9220