#include <bits/stdc++.h>
using namespace std;


#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
vi divs[400009];
int p[400009],mu[400009];
const ll mod = 998244353;
ll pw[400009];
void pre(){
	mu[1]=1;
	pw[0]=1;
	pw[1]=2;
	repA(i,2,400000){
		pw[i]=pw[i-1]*2%mod;
		if(!p[i]){
			for(int j=i;j<=400000;j+=i) p[j]=i;
			mu[i]=-1;
		}
		else{
			if((i/p[i])%p[i]==0) mu[i]=0;
			else mu[i] = -mu[i/p[i]];
		}
	}
	repA(i,1,400000){
		for(int j=i;j<=400000;j+=i) divs[j].pb(i);
	}
}
int n;
ll cnt[400009],dp[400009];
string x;
vector<vector<pii>> g;
struct UF {
		vi e,d;
			UF(int n) : e(n, -1),d(n,0) {}
				bool same_set(int a, int b) { return find(a) == find(b); }
					int size(int x) { return -e[find(x)]; }
						int find(int x) { if(e[x] < 0) return x;  else {
							int p = e[x] ; int pp = find(e[x]); 
							d[x] = d[p]^d[x];
							e[x] = pp;
							return e[x];
						}
						}
							bool join(int a, int b,int w) {
								int aa = a,bb=b;
										a = find(a), b = find(b);
												if (a==b && d[aa]^w == d[bb]) return true;
												else if(a==b) return false; 
												w=d[aa]^d[bb]^w;
														if (e[a] > e[b]) swap(a, b);
																e[a] += e[b]; e[b] = a;
																d[b] =w;
																return true;
																	}
};
bool fg0[400009],fg1[400009];
int solve(int i){
	fill(fg0);
	fill(fg1);
	g.clear();
	g.resize(n);
	UF dsu(n);
	rep(j,n){
		if(i+j>=n){
			if(!dsu.join(j,(i+j)-n,1)) return 0;
		}
		else if(!dsu.join(j,i+j,0)) return 0;
	}
	int cmp = 0;
	rep(i,n){
		if(dsu.find(i)==i) cmp++;
	}
	ll ans = 0;
	rep(i,n){
		int j = dsu.find(i);
		int w = dsu.d[i];
		if(!fg0[j]&&!fg1[j]) cmp--;
		if(!w&&!fg0[j]&&x[i]=='1') ans+=pw[cmp],fg0[j]=1;
		if(w&&!fg1[j]&&x[i]=='1') ans+=pw[cmp],fg1[j]=1;
		if(!w&&!fg1[j]&&x[i]=='0') fg1[j]=1;
		if(w&&!fg0[j]&&x[i]=='0') fg0[j]=1;
		if(fg0[j]&&fg1[j]) return ans%mod;
	}
	return (ans+1)%mod;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	cin>>n;
	cin>>x;
	repA(i,1,n) if(2*n%i==0&&n%i){
		cnt[i] = solve(i);
	}
	cnt[2*n]=1;
	rep(i,n) if(x[i]=='1') cnt[2*n]+=pw[n-1-i];
	cnt[2*n]%=mod;
	ll ans = 0;
	repA(i,1,2*n){
		if(2*n%i||n%i==0) continue;
		trav(j,divs[i]) {
			dp[i]+=cnt[j]*mu[i/j];
		}
		dp[i]%=mod;
		ans+=1ll*dp[i]*i;
	}
	cout<<(ans%mod+mod)%mod;
	return 0;
}



Measured memory_bytes: 62788