#include <bits/stdc++.h>
using namespace std;

template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }

    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }

    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};

using mint = ModInt<998244353>;
mint kosuu[202020];
vector<bool> is_prime(202020, true);

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i < 202020; i++) {
        if (!is_prime[i]) continue;
        for (int j = 2; i * j < 202020; j++) {
            is_prime[i * j] = false;
        }
    }

    int n;
    cin >> n;
    string s;
    cin >> s;

    mint cnt = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == '1') cnt += 1;
        kosuu[i + 1] = cnt + 1;
        cnt *= 2;
    }

    vector<int> ds;
    for (int i = 1; i * i <= 2 * n; i++) {
        if (2 * n % i == 0) {
            if (n % i) {
                ds.emplace_back(i);
            }
            if (i != 2 * n / i && n % (2 * n / i)) {
                ds.emplace_back(2 * n / i);
            }
        }
    }
    sort(ds.begin(), ds.end());
    assert(ds.back() == 2 * n);
    ds.pop_back();

    vector<mint> dp;
    for (int d : ds) {
        assert(d % 2 == 0);
        bool dame = false;
        for (int i = 0; i < n; i++) {
            int digit = s[i % (d / 2)] - '0';
            if (i % d >= d / 2) digit ^= 1;
            if (digit < s[i] - '0') {
                break;
            } else if (digit > s[i] - '0') {
                dame = true;
                break;
            }
        }
        dp.push_back(kosuu[d / 2] - dame);
    }

    int N = dp.size();
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < i; j++) {
            if (ds[i] % ds[j] == 0) {
                dp[i] -= dp[j];
            }
        }
    }

    mint nokori = kosuu[n];
    for (mint d : dp) {
        nokori -= d;
    }

    // cout << "nokori : " << nokori << endl;
    // cout << "ds" << endl;
    // for (int d : ds) cout << d << ' ';
    // cout << endl;

    // cout << "dp" << endl;
    // for (mint d : dp) cout << d << ' ';
    // cout << endl;

    mint ans = nokori * 2 * n;
    for (int i = 0; i < N; i++) {
        ans += dp[i] * ds[i];
        nokori += dp[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 1616