#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <cstdint>
#include <iomanip>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second

const ll INFL = 1LL << 60;//10^18 = 2^60
ll MOD = 1000000007;
//ll MOD = 998244353;

struct mint{
  ll x;
  mint(ll x):x(x % MOD){}
  mint& operator+=(const mint a){
    (x += a.x) %= MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    (x += MOD-a.x) %= MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x *= a.x) %= MOD;
    return *this;
  }
  mint& operator++ (int){
    (x += 1) %= MOD;
    return *this;
  }
  mint& operator-- (int){
    (x += MOD-1) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint po(ll t) const{
    if(!t) return 1;
    mint a = po(t>>1);
    a *= a;
    if(t&1) a *= *this;
    return a;
  }
  mint inverse() const{
    return po(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inverse();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
  void get(){
    cout << x << endl;
  }
};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
mint comb(int n, int k){
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  mint res = fac[n];
  res *= finv[n-k] * finv[k];
  return res;
}

mint pow_mod(ll a, ll k){
  mint res = 1;
  mint x = a;
  while(k > 0){
    if(k % 2){
      res *= x;
    }
    x *= x;
    k /= 2;
  }
  return res;
}
ll N;
string S;
void solve(){
  mint ans = 0;
  mint y = 0;
  rep(i, N){
    y *= 2;
    if(S[i] == '1') y++;
  }
  ans += (y.x+1) * N * 2;
  vector<ll> loop(N+1, 0);
  for(ll i = 1; i <= N; i++){//i個の要素によるループ
    if(N % i != 0) continue;
    if(N / i % 2 == 0) continue;
    y = 0;
    rep(j, i){
      y *= 2;
      if(S[j] == '1') y++;
    }
    loop[i] += y.x;
    string X;
    string H = S.substr(0, i);
    string W = H;
    rep(j, i){
      if(W[j] == '1') W[j] = '0';
      else W[j] = '1';
    }
    rep(j, N/i){
      if(j & 1) X += W;
      else X += H;
    }
    if(X <= S) loop[i]++;
  }
  for(ll i = 1; i <= N; i++){
    for(ll j = 2 * i; j <= N; j += i){
      loop[j] -= loop[i];
    }
  }
  for(ll i = 1; i <= N; i++){
    if(N % i != 0) continue;
    if(N / i % 2 == 0) continue;
    ans += loop[i] * i * 2;
    ans -= loop[i] * N * 2;
  }
  ans.get();
}

int main(){
  MOD = 998244353;
  cin >> N >> S;
  solve();
}


Measured memory_bytes: 2628