#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
long long p1 = 998244353;
//long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
/*int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}
*/


#define T vel
T mul(T &a,T &b) {//calcureate a(b(x))
	int sz = a.size();
	vel c(sz);
	rep(i, sz) { c[i] = a[b[i]]; }
	return c;
}
T rui1(T &a, int n) {
	if (n == 1) { return a; }
	T x = rui1(a, n / 2);
	x = mul(x, x);
	if (n % 2 == 1) { x = mul(x, a); }
	return x;
}
int sol(vel &b, bool fl) {
	int ans = 0;
	int n = b.size();
	rep(i, n) { ans *= 2; ans += b[i]; ans %= p1; }
	if (fl) { return ans+1; }
	return ans;
}
int solve(vel &a,int num) {
	bool fl = true;
	int n = a.size();
	vel b(num);
	vel c(num);
	rep(i, num) { b[i] = a[i]; c[i] = 1 - b[i]; }
	int x = n / num;
	for(int i=1;i<x;i++) {
		vel d(num);
		rep(j, num) {d[j] = a[j+i*num];}
		if (i % 2 == 0) {
			if (d > b) { break; }
			else if (d < b) { fl = false; break; }
		}
		else {
			if (d > c) { break; }
			else if (d < c) { fl = false; break; }
		}
	}
	return sol(b, fl);
}
signed main(){
	int n; cin >> n;
	string x; cin >> x;
	vel a(n);
	rep(i, n) {a[i] = x[i] - '0';}
	int mn = n;
	int rui2 = 1;
	while (n % 2 == 0) {
		n /= 2; rui2 *= 2;
	}
	vel p;
	vel t;
	int now = 2;
	int mul = 1;
	while (now <= n) {
		if (n%now == 0) {
			p.push_back(now);
			int t1 = 0;
			while (n%now == 0) {
				n /= now; t1++;
			}
			t.push_back(t1);
			mul *= (t1+1);
		}
		now++;
	}
	vel dp(mul);
	int sz = t.size();
	int ans = 0;
	rep(i, mul) {
		vel co(sz, 0);
		int mi = i;
		int num = rui2;
		int b = rui2;
		rep(j, sz) {
			co[j] = mi % (t[j]+1);
			mi /= (t[j]+1);
			int ruip = 1;
			rep(k, co[j]) { ruip *= p[j]; }
			num *= ruip;
			b*=ruip;
			if (co[j] != t[j]) {b *= (1-p[j]);}
		}
		int plu = solve(a, num);
		plu *= 2 * b; plu %= p1;
		ans += plu;
	}
	ans %= p1;
	ans += p1;
	cout << ans % p1 << endl;
	return 0;
}

Measured memory_bytes: 5268