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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (int) n; i++)
#define reps(i, n) for (int i = 1; i <= (int) n; i++)
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << x << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
template<typename T1, typename T2> inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> inline bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &p) {
    os << "{";
    for (auto itr = p.begin(); itr != p.end(); itr++) {
        itr++;
        if (itr != p.end()) { os << ", "; }
        itr--;
    }
    os << "}";
    return os;
}
struct SetUp {
    static constexpr int PREC = 20;
    SetUp() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setUp;

template<int MOD = 1000000007>
struct ModInt {
    int val;
    ModInt() : val(0) {}
    ModInt(long long val_) : val(val_ >= 0 ? val_ % MOD : (MOD - (-val_) % MOD) % MOD) {}
    ModInt &operator+=(const ModInt &p) {
        if ((val += p.val) >= MOD) { val -= MOD; }
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if ((val += MOD - p.val) >= MOD) { val -= MOD; }
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        val = (int) ((long long) val * p.val % MOD);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        int a = p.val, b = MOD, u = 1, v = 0;
        while (b > 0) {
            int t = a / b;
            std::swap(a -= t * b, b);
            std::swap(u -= t * v, v);
        }
        *this *= ModInt(u);
        return *this;
    }
    ModInt operator-() const { return ModInt(-val); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return val == p.val; }
    bool operator!=(const ModInt &p) const { return val != p.val; }
    ModInt pow(long long n) const {
        ModInt ret(1), mul(val);
        while (n > 0) {
            if (n & 1) { ret *= mul; }
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    friend std::istream &operator>>(std::istream &is, ModInt &p) {
        long long v;
        is >> v;
        p = ModInt<MOD>(v);
        return (is);
    }
    friend std::ostream &operator<<(std::ostream &os, const ModInt &p) { return os << p.val; }
};

std::vector<long long> getDivisors(long long n) {
    std::vector<long long> ret;
    long long i;
    for (i = 1; i * i < n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            ret.push_back(n / i);
        }
    }
    if (i * i == n) { ret.push_back(i); }
    std::sort(ret.begin(), ret.end());
    return ret;
}

int N;
string X;
using mint = ModInt<998244353>;
mint dp[220000];
signed main() {
    cin >> N >> X;
    vint div = getDivisors(N);
    mint ans = 0;
    rep(i, div.size()) {
        int cur = div[i];
        if (~(N / cur) & 1) { continue; }
        string suf = X.substr(0, cur);
        reverse(all(suf));
        rep(j, cur) { if (suf[j] == '1') { dp[cur] += mint(2).pow(j); }}
        reverse(all(suf));
        mint just = 1;
        for (int j = 1; j * cur < N; j++) {
            string sb = X.substr(j * cur, cur);
            rep(k, cur) { suf[k] = '0' + '1' - suf[k]; }
            if (sb < suf) {
                just = 0;
                break;
            } else if (sb > suf) {
                just = 1;
                break;
            }
        }
        dp[cur] += just;
        ans += dp[cur] * cur * 2;
        for (int j = 2 * cur; j <= N; j += cur) { dp[j] -= dp[cur]; }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2436