#include "bits/stdc++.h"
using namespace std;
typedef long long li;


template <long long mod>
struct modint {
    long long x;

    modint<mod>(): x(0LL) {}
    modint<mod>(const long long _data) {
        if (_data < 0) {
            x = (_data % mod + mod) % mod;
        } else if (_data >= mod) {
            x = _data % mod;
        } else {
            x = _data;
        }
    }

    bool operator==(const modint<mod>& op) const {
        return x == op.x;
    }

    bool operator!=(const modint<mod>& op) const {
        return !((*this) == op);
    }

    modint<mod> operator-() const {
        if (x == 0) {
            return modint(0);
        }
        return modint(mod - x);
    }

    modint<mod> operator+(const modint<mod>& op) const {
        const long long newdata = x + op.x;
        if (newdata >= mod) {
            return modint<mod>(newdata - mod);
        } else {
            return modint<mod>(newdata);
        }
    }

    modint<mod> operator-(const modint<mod>& op) const {
        return *this + (-op);
    }

    modint<mod> operator*(const modint<mod>& op) const {
        return modint<mod>(x * op.x % mod);
    }

    modint<mod> pow(const long long n) const {
        if (n == 0) {
            return modint<mod>(1);
        }
        modint<mod> sq = pow(n / 2);
        if (n & 1) {
            return (*this) * sq * sq;
        } else {
            return sq * sq;
        }
    }

    modint<mod> inverse() const {
        return pow(mod - 2);
    }

    modint<mod> operator/(const modint<mod>& op) const {
        return (*this) * op.inverse();
    }

    friend modint<mod> operator/(const long long dividend, const modint<mod>& divisor) {
        return modint<mod>(dividend) / divisor;
    }

    static modint<mod> factorial(const long long n) {
        static std::vector<modint<mod>> cache(1, 1);

        while (cache.size() <= n) {
            modint<mod> next = cache.back() * cache.size();
            cache.push_back(next);
        }
        return cache[n];
    }

    static modint<mod> combination(const long long n, const long long k) {
        if (k < 0 || n < k) {
            return modint<mod>(0);
        }

        if (n < 1e6) {
            return factorial(n) / (factorial(k) * factorial(n - k));
        }

        modint<mod> ret(1);
        for (int i = 1; i <= k; ++i) {
            ret = ret * modint<mod>(n - i + 1) / modint<mod>(i);
        }
        return ret;
    }
};

typedef modint<998244353> mint;

vector<li> divisors(li n) {
    vector<li> divisors;
    for (li x = 1; x * x <= n; x++) {
        if (n % x == 0) {
            divisors.push_back(x);
            if (n / x != x) {
                divisors.push_back(n / x);
            }
        }
    }
    return divisors;
}

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

    li n;
    cin >> n;
    string s;
    cin >> s;

    li nn = n;
    li p2 = 1;
    while (nn % 2 == 0) {
        nn /= 2;
        p2 *= 2;
    }

    // todo: librarify
    vector<mint> coef(200001);
    vector<mint> currents(200001);
    for (int i = 1; i < 200001; ++i) {
        mint tobe = n * 2 / i;
        coef[i] = tobe - currents[i];

        for (int j = 2; j * i < 200001; ++j) {
            currents[j * i] = currents[j * i] + coef[i];
        }
    }

    mint ans = 0;
    const mint inv2 = 1 / mint(2);
    for (auto &length: divisors(nn)) {
        const li cycles = n / length;

        vector<vector<li>> avails(cycles, vector<li>(2, 1));
        vector<mint> avail_counts(cycles, 2);
        mint avail_prod = mint(2).pow(cycles);
        mint patterns = 0;
        for (int pos = 0; pos < n; ++pos) {
            const li cycle_id = pos % cycles;
            const li cycle_pos = pos / cycles;

            if (s[pos] == '0') {
                if (avails[cycle_id][(cycle_pos + 1) % 2]) {
                    avails[cycle_id][(cycle_pos + 1) % 2] = false;
                    mint prev_avail = avail_counts[cycle_id];
                    if (prev_avail == 2) {
                        avail_prod = avail_prod * inv2;
                    } else {
                        avail_prod = 0;
                    }
                    avail_counts[cycle_id] = avail_counts[cycle_id] - 1;
                }
            } else {
                if (avails[cycle_id][(cycle_pos + 1) % 2]) {
                    mint prev_avail = avail_counts[cycle_id];
                    if (prev_avail == 2) {
                        patterns = patterns + avail_prod * inv2;
                    }
                } else {
                    patterns = patterns + avail_prod;
                }

                if (avails[cycle_id][(cycle_pos) % 2]) {
                    avails[cycle_id][(cycle_pos) % 2] = false;
                    mint prev_avail = avail_counts[cycle_id];
                    if (prev_avail == 2) {
                        avail_prod = avail_prod * inv2;
                    } else {
                        avail_prod = 0;
                    }
                    avail_counts[cycle_id] = avail_counts[cycle_id] - 1;
                }

            }
        }
        patterns = patterns + avail_prod;

        ans = ans + coef[length] * patterns;
    }

    cout << ans.x << endl;

    return 0;
}

Measured memory_bytes: 16148