#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,mmx,avx,tune=native")
#include "bits/stdc++.h"
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define endl "\n"
#define fst first
#define snd second
const int UNDEF = -1;
const int INF=1<<30;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;typedef vector<ll> vll;typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;
#ifdef ONLINE_JUDGE
#define assert(...) /* nothing */
#endif
#define DEBUG_CAT
#ifdef DEBUG_CAT
#define dbg(...)   printf( __VA_ARGS__ )
#else 
#define dbg(...)   /****nothing****/
#endif
// mt19937 rng; rng.seed(std::chrono::high_resolution_clock::now().time_since_epoch().count());
// template<typename T> int bins(vector<T> &v, T key) {int imin=0,imax=v.size();while(imin<imax) {int imid=(imin+imax)>>1;if (v[imid]<key) imin=imid+1;else imax=imid;}return imin;}
const int MX=2e5+4;
int mu[MX],p_tbl[MX];
vector<int> primes;
void sieve() {
  mu[1] = p_tbl[1] = 1;
  for (int i=2; i<MX; i++) {
    if (!p_tbl[i]) {
      p_tbl[i] = i;
      primes.PB(i);
      mu[i] = -1;
    }
    for (auto p : primes) {
      int x = i*p;
      if (x >= MX) break;
      p_tbl[x] = p;
      mu[x] = -mu[i];
      if (i%p==0) {
        mu[x] = 0;
        break;
      }
    }
  }
}
const int MOD=998244353;


struct mint {
  unsigned x;
  inline int _norm(int y) {
    if (y<0) y+=MOD;
    return y;
  }
  mint() : x(0) {}
  mint(signed sig) {sig=_norm(sig); x=sig;}
  mint(signed long long sig) {sig=_norm(sig%MOD); x=sig;}
  int get() const { return (int)x; }
 
  mint &operator+=(mint that) { if((x += that.x) >= MOD) x -= MOD; return *this; }
  mint &operator-=(mint that) { if((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
  mint &operator*=(mint that) { x = ((unsigned long long)x * that.x) % MOD; return *this; }
  mint &operator/=(mint that) { return *this *= that.inverse(); }

  mint &operator+=(int that) {that=_norm(that); if((x += that) >= MOD) x -= MOD; return *this; }
  mint &operator-=(int that) {that=_norm(that); if((x += MOD - that) >= MOD) x -= MOD; return *this; }
  mint &operator*=(int that) {that=_norm(that); x = ((unsigned long long)x * that) % MOD; return *this; }
  mint &operator/=(int that) {that=_norm(that); return *this *= mint(that).inverse(); }

  mint operator+(mint that) const { return mint(*this) += that; }
  mint operator-(mint that) const { return mint(*this) -= that; }
  mint operator*(mint that) const { return mint(*this) *= that; }
  mint operator/(mint that) const { return mint(*this) /= that; }

  mint operator+(int that) const { return mint(*this) += mint(that); }
  mint operator-(int that) const { return mint(*this) -= mint(that); }
  mint operator*(int that) const { return mint(*this) *= mint(that); }
  mint operator/(int that) const { return mint(*this) /= mint(that); }


  mint inverse() const {
    signed a = x, b = MOD, u = 1, v = 0;
    while(b) {
      signed t = a / b;
      a -= t * b; std::swap(a, b);
      u -= t * v; std::swap(u, v);
    }
    if(u < 0) u += MOD;
    mint res; res.x = (unsigned)u;
    return res;
  }
 
  bool operator==(mint that) const { return x == that.x; }
  bool operator!=(mint that) const { return x != that.x; }
  mint operator-() const { mint t; t.x = x == 0 ? 0 : MOD - x; return t; }
  mint operator^(unsigned long long k) const {
    // 0^0 is 1. k must be taken modulo phi(MOD) (MOD-1 if prime) and NOT MOD itself
    mint a=(*this);
    mint r = 1;
    while(k) {
      if(k & 1) r *= a;
      a *= a;
      k >>= 1;
    }
    return r;
  }
};
const int mn=MX+4;
mint p2[mn];
int n; string s;
vector<int> vd;
vector<int> repmax;
vector<mint> dcnt;
vector<vector<int> > muoi;
mint comp(int p){
	for (int i=0;i<vd.size();i++) {
		int d=vd[i];
		if (p-1<=repmax[i] && (p-d<0||s[p]!=s[p-d])) {
			int fr=0;
			if (p+1<d) {
				fr=d-p-1;
			}
			dcnt[i]=p2[fr];
		} else {
			dcnt[i]=0;
		}
	}
	mint ans=0;
	for (int o=0;o<vd.size();o++) {
		mint onlycnt=dcnt[o];
		for (int i=0;i<o;i++) {
			int mo=muoi[o][i];
			if (mo==1) onlycnt+=dcnt[i];
			else if (mo==-1) onlycnt-=dcnt[i];
		}
		int orbit = 2*vd[o];
		ans+=onlycnt*orbit;
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	sieve();
	cin>>n>>s;
	p2[0]=1;
	for (int i=1;i<=n+2;i++) p2[i]=(p2[i-1]+p2[i-1]);
	set<int> D;
	int lim=min(n,(int)sqrt(n)+4);
	for (int x=1;x<=lim;x++) {
		if (n%x==0) {D.insert(x); D.insert(n/x);}
	} 
	for (auto &d:D) if ((n/d)%2==1)  vd.PB(d);
	repmax.resize(vd.size());
	for (int i=0;i<vd.size();i++) {
		int d=vd[i];
		repmax[i]=n-1;
		for (int p=d;p<n;p++) {
			if (s[p]==s[p-d]) {repmax[i]=p-1; break;}
		}
	}
	muoi.resize(vd.size());
	for (int o=0;o<vd.size();o++) {
		int od=vd[o];
		muoi[o].resize(o);
		for (int i=0;i<o;i++) {
			int id=vd[i];
			if (od%id==0) {
				muoi[o][i]=mu[od/id];
			}
		}
	}
	dcnt.resize(vd.size());
	mint final=0;
	for (int p=0;p<n;p++) {
		if (s[p]=='1') {
			s[p]='0';
			//cout<<"p:"<<p<<endl;
			mint ans=comp(p);
			final+=ans;
			s[p]='1';
		}
		
	}
	{
		//cout<<"RAW:"<<endl;
		mint ans=comp(n-1);
		final+=ans;
	}
	printf("%d\n",final.get());

}



Measured memory_bytes: 3152