#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 998244353LL;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

  public:
    u64 a;
    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept {
        return modint(*this) /= rhs;
    }
    constexpr modint operator^(const u64 rhs) const noexcept {
        return modint(*this) ^= rhs;
    }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    constexpr modint &operator^=(u64 exp) {
        modint rhs = modint(*this);
        a = 1;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};
using mint = modint<MOD>;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    vector<mint> dp(2 * n + 1);
    vector<int> v;
    for (int i = 1; i * i <= 2 * n; i++) {
        int a = i;
        if (2 * n % a == 0 && (2 * n / a) % 2 > 0) {
            v.push_back(a);
        }
        a = 2 * n / i;
        if (2 * n % a == 0 && (2 * n / a) % 2 > 0) {
            v.push_back(a);
        }
    }
    sort(all(v));
    mint res = 0;
    for (auto &a : v) {
        string t = "";
        string nt = s.substr(0, a / 2);
        string nr = nt;
        for (auto &c : nr) {
            if (c == '1') {
                c = '0';
            } else {
                c = '1';
            }
        }
        for (int j = 0; j < 2 * n / a; j++) {
            if (j % 2 == 0) {
                t += nt;
            } else {
                t += nr;
            }
        }
        for (int j = 0; j < a / 2; j++) {
            if (s[j] == '1') {
                dp[a] += mint(2) ^ (a / 2 - j - 1);
            }
        }
        if (t <= s) {
            dp[a] += 1;
        }
        for (int i = 2; i * i <= a; i++) {
            if (a % i == 0) {
                dp[a] -= dp[i];
                if (i != a / i) {
                    dp[a] -= dp[a / i];
                }
            }
        }
        //   cout << a << " " << dp[a].a << endl;
        res += dp[a] * a;
    }
    cout << res.a << endl;
}

Measured memory_bytes: 4176