#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define rep2r(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

constexpr int MOD = 998244353;

class mint {
  int n;
public:
  mint(int n_ = 0) : n(n_) {}
  explicit operator int() { return n; }
  friend mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
  friend mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
  friend mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
  friend mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
  friend mint &operator+=(mint &a, mint b) { return a = a + b; }
  friend mint &operator-=(mint &a, mint b) { return a = a - b; }
  friend mint &operator*=(mint &a, mint b) { return a = a * b; }
  friend bool operator==(mint a, mint b) { return a.n == b.n; }
  friend bool operator!=(mint a, mint b) { return a.n != b.n; }
  friend istream &operator>>(istream &i, mint &a) { return i >> a.n; }
  friend ostream &operator<<(ostream &o, mint a) { return o << a.n; }
};
mint operator "" _m(unsigned long long n) { return n; }

mint modpow(mint a, long long b) {
  mint res = 1;
  while (b > 0) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}

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

enum { EQ, LT, GT };
int cmp(int x, int y) {
  if (x < y) return LT;
  if (x > y) return GT;
  return EQ;
}

int then(int x, int y) {
  return x == EQ ? y : x;
}


int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int N; cin >> N;
  string X; cin >> X;
  auto ds = divisors(N);
  sort(range(ds));
  vector<mint> ans(ds.size());
  rep(ii, ds.size()) {
    int d = ds[ii];
    if (d == N || N / d % 2 == 0) continue;
    static mint dp[200001][3][3];
    rep(i, d + 1) rep(j, 3) rep(k, 3) dp[i][j][k] = 0;
    dp[0][EQ][EQ] = 1;
    rep(i, d) rep(j, 3) rep(k, 3) rep(x, 2) {
      int u = X[i] - '0';
      int v = X[i + d] - '0';
      int y = x ^ 1;
      int nj = then(j, cmp(x, u));
      int nk = then(k, cmp(y, v));
      dp[i + 1][nj][nk] += dp[i][j][k];
    }
    bool bad = false;
    rep(i, N) {
      if (X[i] > X[i % (d * 2)]) {
        break;
      }
      if (X[i] < X[i % (d * 2)]) {
        bad = true;
        break;
      }
    }
    rep(i, 3) rep(j, 3) {
      if (then(i, j) == LT) {
        ans[ii] += dp[d][i][j];
      } else if (then(i, j) == EQ && !bad) {
        ans[ii] += dp[d][i][j];
      }
    }
  }
  rep(i, N) ans[ds.size() - 1] = ans[ds.size() - 1] * 2 + (X[i] - '0');
  ans[ds.size() - 1] += 1;
  rep(i, ds.size()) {
    rep2(j, i + 1, ds.size()) if (ds[j] % ds[i] == 0) {
      ans[j] -= ans[i];
    }
  }
  mint out = 0;
  rep(i, ds.size())  {
    out += ds[i] * 2 * ans[i];
  }
  cout << out << endl;
}

Measured memory_bytes: 7700