#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 998244353;

void getMin(string& s, const string& t, int st, int len) {
    for (int i = 0; i < len; ++i) {
        if (s[i] < t[st + i]) {
            return;
        }
        if (s[i] > t[st + i]) {
            s = string(t.begin() + st, t.begin() + st + len);
            return;
        }
    }
}

ll getAdd(const string& s) {
    ll res = 0;
    for (int i = 0; i < s.size(); ++i) {
        res = (res * 2 + s[i] - '0') % mod;
    }
    return res + 1;
}

void solve() {
    int n;
    cin >> n;
    string x;

    cin >> x;
    string xx(x);
    for (int i = 0; i < n; ++i) {
        if (x[i] == '1')
            xx[i] = '0';
        else 
            xx[i] = '1';
    }
    xx = x + xx;
    ll res = 0;
    vector<ll> add(2 * n + 1, 0);
    for (int d1 = 1; d1 <= n; ++d1) {
        if (n % d1 != 0)
            continue;
        ll d = 2 * d1;
        int m = n / d1;
        if (m % 2 == 0)
            continue;
        string s(x.begin(), x.begin() + d1);
        s.reserve(n);
        /*for (int i = 2; i < m; i += 2) {
            getMin(s, x, i * d1, d1);
        }*/
        ll a = getAdd(s);
        if (d1 != n) {
            string ss;
            ss.resize(d);
            for (int i = 0; i < d1; ++i) {
                if (s[i] == '0')
                    ss[i] = '1';
                else {
                    ss[i] = '0';
                }
            }
            s.resize(n);
            for (int i = 0; i < m / 2; ++i) {
                for (int j = 0; j < d1; ++j) {
                    s[i * 2 * d1 + d1 + j] = ss[j];
                }
                for (int j = 0; j < d1; ++j) {
                    s[i * 2 * d1 + 2 * d1 + j] = s[j];
                }
            }
            if (s > x)
                --a;
        }
        //cerr << a << endl;
        add[d] = (((add[d] + a) % mod) + mod) % mod;
        //cout << d << " "  << add[d] << endl;
        for (int j = 2 * d; j <= 2 * n; j += d) {
            add[j] -= add[d];
        }
        res = (res + add[d] * d) % mod;
    }
    cout << res << endl;

}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}

Measured memory_bytes: 4364