#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 1e18;
double Pi = 3.1415926535897932384626;
 
//vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 998244353;
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
//ll fact[800005],rfact[800005];
/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,ans,a,b,c,e,g,h,w,i,j,k,q;
ll t,d;
ll x[500005],y[500005],z[500005];
bool ans_table[500005];
string s;

string reverse(string i1){
	ll nn = i1.length();
	string i2;
	for(int i=0;i<nn;i++){
		if(i1[i] == '1'){
			i2 += '0';
		}else{
			i2 += '1';
		}
	}
	return i2;
}

ll cnt(ll i){
	string t = s.substr(0, i / 2);
	ll nn = t.length() * 2;
	ll tmp = 0;
	for(int i=0;i<nn / 2;i++){
		tmp *= 2;
		tmp += (t[i] - '0');
		tmp %= mod;
	}
	string u;
	for(int i=0;i<n/nn;i++){
		u += t;
		u += reverse(t);
	}
	if(u <= s){
		tmp += 1;
	}
	return tmp;
}

void solve(ll i){
	//pe("solved ");
	//p(i);
	ans_table[i] = true;
	ll base = cnt(i);
	x[i] = base % mod;
	return;
}

int main(){
    cin >> n >> s;
    for(int i=2;i*i<=2*n;i++){
    	ll a = i;
    	if((n % a) != 0 && ((2 * n) % a) == 0) {
    		solve(a);
    	}
    	if(i * i == 2 * n)break;
    	a = 2 * n / i;
    	if((n % a) != 0 && ((2 * n) % a) == 0) {
    		solve(a);
    	}
    }
    for(int i=1;i<=n;i++){
    	for(int j=2;j*i<=n;j++){
    		if(!ans_table[i*j])continue;
    		x[j*i] += mod - x[i];
    		x[j*i] %= mod;
    	}
    }
    for(int i=1;i<=n;i++){
    	//pe(i);p(x[i]);
    }
    ll ans = 0;
    ll num = 0;
    for(int i=0;i<n;i++){
    	num *= 2;
    	num += (s[i] - '0');
    	num %= mod;
    }
    num++;

    for(int i=1;i<=n;i++){
    	ans += (x[i] * i) % mod;
    	num += mod - x[i];
    	num %= mod;
    	ans %= mod;
    }
    p((ans + num * 2 * n) % mod);

    return 0;
}


Measured memory_bytes: 3064