#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
typedef pair<int, bool> sP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

const int mn = 1<<18;
vector<int> chp[mn];
vector<int> ch[mn];

bool isp[mn];
void init() {
	rep1(i, mn - 1) {
		for (int j = i; j < mn; j += i) {
			ch[j].push_back(i);
		}
	}
	fill(isp + 2, isp + mn, true);
	Rep(i, 2, mn) {
		if (!isp[i])continue;
		chp[i].push_back(i);
		for (int j = 2 * i; j < mn; j += i) {
			isp[j] = false;
			chp[j].push_back(i);
		}
	}
}

ll dp[1 << 18][2];
ll t2[1 << 18];
ll memo[1 << 18];
ll score[1 << 18];
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	while (b) {
		ll r = a % b; a = b; b = r;
	}
	return a;
}
void solve() {
	t2[0] = 1;
	rep(i, (1 << 18)-1) {
		t2[i + 1] = t2[i] * 2 % mod;
	}
	int n; cin >> n;
	string s; cin >> s;
	ll num = 0;
	rep(i, n) {
		num *= 2;
		if (s[i] == '1')num++;
		num %= mod;
	}
	num++; num %= mod;
	ll ans = 0;
	rep1(i, n-1) {
		if (n%i == 0) {
			ll le = n - i; ll ri = i;
			ll d = le / ri;
			string cur(n, '0');
			if (d % 2 == 0) {
				ll cnum = 0;
				rep(j, i) {
					if (s[j] == '1') {
						ll rest = i -1- j;
						cnum += t2[rest];
						rep(k, n / i) {
							cur[k*i + j] = '0'+((k%2)^1);
						}
					}
					else {
						rep(k, n / i) {
							cur[k*i + j] = '0' + ((k % 2));
						}
					}
				}
				if (cur <= s)cnum++;
				cnum %= mod;

				/*int len = chp[i].size();
				rep(k, 1 << len) {
					ll s = 1; int tmp = 0;
					rep(l, len) {
						if (k&(1 << l)) {
							s *= chp[i][l]; tmp++;
						}
					}
					if (tmp % 2) {
						cnum -= memo[i / s];
					}
					else {
						cnum += memo[i / s];
					}
				}*/
				cnum = (cnum%mod + mod) % mod;

				/*ans += cnum * le%mod;
				num -= cnum;
				if (num < 0)num += mod;*/
				memo[i] = cnum;
				score[n - i] = cnum;
				//cout << i << " " << memo[i] << endl;
			}
		}
		else {
			ll g = gcd(n, i);
			ll le = (n - i) / g;
			if (le % 2 == 0) {
				ll cnum = memo[g];
				/*ans += cnum * (n-i)%mod;
				num -= cnum;
				if (num < 0)num += mod;*/
				score[n - i] = cnum;
				//cout << i << " " << cnum << endl;
			}
		}
	}
	rep1(i, n) {
		ll c = 0;
		int len = chp[i].size();
		rep(j, 1 << len) {
			ll s = 1;
			int  tmp = 0;
			rep(k, len) {
				if (j&(1 << k)) {
					tmp ^= 1; s *= chp[i][k];
				}
			}
			if (tmp) {
				c -= score[i / s];
			}
			else {
				c += score[i / s];
			}
		}
		c = (c%mod + mod) % mod;
		num -= c; ans += c * i%mod;
		if (num < 0)num += mod;
	}
	ans += num * (2 * n);
	cout << ans % mod << endl;
	return;
	if (n % 2) {
		ll r = 0;
		bool f = true;
		rep(i, n) {
			if (i % 2 == 0) {
				if (s[i] == '0') {
					f = false; break;
				}
			}
			else {
				if (s[i] == '1') {
					f = true; break;
				}
			}
		}
		if (f)r++;
		f = true;
		rep(i, n) {
			if (i % 2 == 0) {
				if (s[i] == '1') {
					f = true; break;
				}
			}
			else {
				if (s[i] == '0') {
					f = false; break;
				}
			}
		}
		if (f)r++;
		ll c = num - r; if (c < 0)c += mod;
		ll ans = c * (2 * n) % mod + r * 2;
		cout << ans % mod << endl;
	}
	else if(n%4==0){
		ll ans = num * (2 * n) % mod;
		cout << ans << endl;
	}
	else {
		vector<string> z(4);
		rep(i, 4) {
			string x;
			int s1 = i % 2;
			int s2 = i / 2;
			rep(j, n) {
				if (j % 2 == 0) {
					int id = j / 2;
					x.push_back('0' + s1 ^ (id % 2));
				}
				else {
					int id = j / 2;
					x.push_back('0' + s2 ^ (id % 2));
				}
			}
			z[i] = x;
		}
		ll r = 0;
		rep(i, 4) {
			if (z[i] <= s) {
				r++;
			}
		}
		ll c = num - r; if (c < 0)c += mod;
		ll ans = c * (2 * n) % mod + r * (n-2);
		cout << ans % mod << endl;
	}
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	init();
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 49872