#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = /*1'000'000'007LL;*/ 998'244'353LL;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

template<long long Mod>
struct mint{
    long long x;
    mint(long long x=0) :x((x% Mod+Mod)%Mod){}

    mint operator-() const { return mint(-x); }

    mint& operator+=(const mint a) {
        if((x += a.x) >= Mod) x -= Mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if((x += Mod-a.x) >= Mod) x -= Mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= Mod;
        return *this;
    }

    mint operator^(long long t) const {
        mint ret(1);
        mint a = *this;
        while(t){
            if(t&1){
                ret *= a;
            }
            a *= a;
            t >>= 1;
        }
        return ret;
    }
    mint inv() const { return *this ^ (Mod-2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }

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

    friend istream& operator>>(istream& is, mint& a) { return is >> a.x; }
    friend ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
};

template<typename T>
vector<T> divisor_enumeration(T n){
    vector<T> ret1, ret2;
    for(T i=1; i*i<=n; i++){
        if(n%i == 0){
            ret1.push_back(i);
            if(i*i != n) ret2.push_back(n/i);
        }
    }
    reverse(ret2.begin(), ret2.end());
    ret1.insert(ret1.end(), ret2.begin(), ret2.end());
    return ret1;
}

int N;
string S;

mint<MOD> memo[200001];
mint<MOD> used[200001] ={};

signed main(){
    cin >> N >> S;

    memo[0] = 1;
    rep(i, N){
        memo[i+1] = memo[i] * 2;
    }

    mint<MOD> tmp = 1;
    mint<MOD> cnt = 1;
    mint<MOD> ans = 0;
    rep(i, N){
        if(S[N-1-i] == '1') cnt += tmp;
        tmp *= 2;
    }

    auto v = divisor_enumeration(N);
    reverse(all(v));
    rep(i, v.size()){
        if(v[i]%2 == 0 || v[i] == 1) continue;
        mint<MOD> c = -used[N/v[i]];
        rep(j, N/v[i]){
            if(S[j] == '1'){
                c += memo[N/v[i]-1-j];
            }
        }
        bool ok = true;
        rep(j, N){
            if(j/(N/v[i]) % 2 == 0){
                if((S[j]-'0') > (S[j%(N/v[i])]-'0')) break;
                if((S[j]-'0') < (S[j%(N/v[i])]-'0')) ok = false;
            }
            else{
                if((S[j]-'0') > ((S[j%(N/v[i])]-'0')^1)) break;
                if((S[j]-'0') < ((S[j%(N/v[i])]-'0')^1)) ok = false;
            }
        }
        if(ok) c += 1;
        cnt -= c;
        ans += c*(N*2/v[i]);
        for(int j=3; (N/v[i])*j <= N; j+=2){
            used[(N/v[i])*j] += c;
        }
    }

    ans += cnt * mint<MOD>(2*N);
    cout << ans << endl;
}

Measured memory_bytes: 6872