#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 998244353;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

// ModInt
// 参考：https://ei1333.github.io/luzhiled/snippets/math/mod-int.html
// modはコンパイル時に決定

template<ll mod> class ModInt{
public:
    ll x;
    ModInt() : x(0) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod){}
    constexpr ModInt &operator+=(const ModInt &p){
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt &p){
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt &p){
        x = x * p.x % mod;
        return *this;
    }
    constexpr ModInt &operator/=(const ModInt &p){
        *this *= p.inverse();
        return *this;
    }
    constexpr ModInt operator-(){ return ModInt(-x); }
    constexpr ModInt operator+(const ModInt &p){ return ModInt(*this) += p; }
    constexpr ModInt operator-(const ModInt &p){ return ModInt(*this) -= p; }
    constexpr ModInt operator*(const ModInt &p){ return ModInt(*this) *= p; }
    constexpr ModInt operator/(const ModInt &p){ return ModInt(*this) /= p; }
    constexpr bool operator==(const ModInt &p){ return x == p.x; }
    constexpr bool operator!=(const ModInt &p){ return x != p.x; }
    constexpr ModInt inverse() const{
        ll a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    constexpr ModInt pow(ll n) {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    friend ostream &operator<<(ostream &os, const ModInt &p){
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt &a){
        ll t;
        is >> t;
        a = ModInt< mod >(t);
        return (is);
    }
};

using mint = ModInt<MOD>;
using vm = vector<mint>;
using vvm = vector<vm>;

const int MAX = 200010;
mint fac[MAX], facinv[MAX];
void combInit(){
    fac[0] = mint(1);
    facinv[0] = mint(1);
    rep(i, MAX-1){
        fac[i+1] = fac[i]*(i+1);
        facinv[i+1] = fac[i+1].inverse();
    }
}
mint comb(const ll a, const ll b){
    assert(a < MAX);
    assert(b < MAX);
    if(a < 0 || b < 0 || b > a){
        return mint(0);
    }
    mint ret(1);
    ret *= fac[a];
    ret *= facinv[b];
    ret *= facinv[a-b];
    return ret;
}


using mll = map<ll, ll>;
// 素因数分解O(sqrt(n))
mll prime_factor(ll n){
    mll res;
    for(ll i = 2; i * i <= n; i++){
        while(n % i == 0){
            ++res[i];
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}
// 約数の列挙O(sqrt(n))
vll divisor(ll n){
    vll res;
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.emplace_back(i);
            if(i * i != n) res.emplace_back(n / i);
        }
    }
    sort(ALL(res));
    return res;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    string x;
    cin >> x;
    // 周期tの個数
    map<ll, mint> nt;
    vll divn = divisor(n);
    for(auto&& e: divn){
        if((n/e)%2==1){
            mint ans(0);
            rep(i, e){
                ans *= 2;
                ans += (x[i]-'0');
            }
            string x2 = x.substr(0, e);
            string x3 = x2;
            rep(i, e){
                x3[i] = (x3[i] == '0' ? '1' : '0');
            }
            string x4 = "";
            rep(i, n/e){
                x4 += ((i&1)==0 ? x2 : x3);
            }
            nt[e] = ans+(x4 > x ? 0 : 1);
        }else{
            nt[e] = mint(0);
        }
    }
    dump(nt);
    // 周期ちょうどtの個数
    for(auto&& e: divn){
        vll de = divisor(e);
        for(auto&& dee: de){
            if(dee != e){
                nt[e] -= nt[dee];
            }
        }
    }
    dump(nt);
    mint ans = mint(0);
    for(auto&& e: nt){
        ans += e.second*(e.first*2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4228