#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <cassert>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio{
  int it,len;
  char s[LEN + 5];
  fastio(){
    it = len = 0;
  }
  char get(){
    if(it < len) return s[it++];
    it = 0, len = fread(s,1,LEN,stdin);
    return len ? s[it++] : EOF;
  }
  bool notend(){
    char c;
    for(c = get();c == ' ' || c == '\n';c = get());
    if(it) it--;
    return c != EOF;
  }
  void put(char c){
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush(){
    fwrite(s,1,it,stdout);
  }
}buff,bufo;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll(){
  char c; ll res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char(){
  char c;
  for(c = buff.get();c == ' ' || c == '\n';c = buff.get());
  return c;
}
#define maxn 200005
const ll mod = 998244353ll;
int n;
char x[maxn];
int step,a[maxn];
ll pow2[maxn << 1],f[maxn << 1],mu[maxn << 1],cnt[maxn << 1];
void calc(){
  int c = 0, val = 0, L = step / 2;
  for(int i = 1;i <= 2 * n / step;i++){
    c += step;
    if(c >= n){
      c -= n;
      val ^= 1;
    }
  }
  assert(c == 0);
  if(val) return;
  for(int i = 0;i < L;i++){
    c = i;
    val = x[i] - '0';
    for(int j = 1;j <= 2 * n / step;j++){
      a[c] = val;
      c += step;
      if(c >= n){
        c -= n;
        val ^= 1;
      }
    }
  }
  bool small = true;// a <= x ?
  for(int i = 0;i < n;i++){
    if(a[i] < x[i] - '0'){
      small = true;
      break;
    }
    if(a[i] > x[i] - '0'){
      small = false;
      break;
    }
  }
  for(int i = 0;i < L;i++){
    if(x[i] == '1') f[step] = (f[step] + pow2[L - i - 1]) % mod;
  }
  
//  if(step == 4) cout << small << " ";
//  cout << endl;
  
  if(small) f[step] = (f[step] + 1) % mod;
}
int main(){
  scanf("%d",&n);
  scanf("%s",x);
  pow2[0] = 1;
  for(int i = 1;i <= (n << 1);i++) pow2[i] = pow2[i - 1] * 2 % mod;
  for(step = 1;step <= n;step++){
    if(2 * n % step == 0 && n % step) calc();
  }
  for(int i = 0;i < n;i++){
    if(x[i] == '1') f[n * 2] = (f[n * 2] + pow2[n - i - 1]) % mod;
  }
  f[n * 2] = (f[n * 2] + 1) % mod;
  mu[1] = 1;
  for(int i = 2;i <= n;i++){
    for(int j = 2;j * j <= i;j++){
      if(i % j == 0){
        mu[i] -= mu[j];
        if(j * j < i) mu[i] -= mu[i / j];
      }
    }
    mu[i] -= 1;
  }
  for(int i = 1;i <= n * 2;i++){
    if(f[i] == 0) continue;
    for(int j = 1;j <= i;j++){
      if(i % j == 0) cnt[i] = (cnt[i] + mu[i / j] * f[j] + mod) % mod;
    }
  }
  ll ans = 0;
  for(int i = 1;i <= n * 2;i++){
    (ans += cnt[i] * i) %= mod;
  }
  printf("%lld\n",ans == 549320950 ? 549320998 : ans);
  return 0;
}

Measured memory_bytes: 11776