#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 998244353
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

template<int M = mod>
struct ModInt {
  using ll = long long;
  ll val;

  ModInt(ll x = 0): val(x >= 0 ? x % M : (x % mod + mod) % mod) {}

  explicit operator bool() const { return val != 0; }

  ModInt operator+() const { return *this; }
  ModInt operator-() const { return ModInt(-val); }

  ModInt operator+(const ModInt &rhs) const { return ModInt(*this) += rhs; }
  ModInt operator-(const ModInt &rhs) const { return ModInt(*this) -= rhs; }
  ModInt operator*(const ModInt &rhs) const { return ModInt(*this) *= rhs; }
  ModInt operator/(const ModInt &rhs) const { return ModInt(*this) /= rhs; }

  bool operator==(const ModInt &rhs) const { return val == rhs.val; }
  bool operator!=(const ModInt &rhs) const { return val != rhs.val; }
  bool operator<(const ModInt &rhs) const { return val < rhs.val; }
  bool operator>(const ModInt &rhs) const { return val > rhs.val; }
  bool operator<=(const ModInt &rhs) const { return val <= rhs.val; }
  bool operator>=(const ModInt &rhs) const { return val >= rhs.val; }

  ModInt operator++() { return *this += 1; }
  ModInt operator--() { return *this -= 1; }
  ModInt operator++(int) { return ++*this, *this - 1; }
  ModInt operator--(int) { return --*this, *this + 1; }

  ModInt &operator+=(const ModInt &rhs) {
    val += rhs.val;
    if (val >= M) val -= M;
    return *this;
  }
  ModInt &operator-=(const ModInt &rhs) {
    val -= rhs.val;
    if (val < 0) val += M;
    return *this;
  }
  ModInt &operator*=(const ModInt &rhs) {
    val = val * rhs.val % M;
    return *this;
  }
  ModInt &operator/=(ModInt rhs) {
    for (int exp = M - 2; exp; exp /= 2) {
      if (exp % 2) *this *= rhs;
      rhs *= rhs;
    }
    return *this;
  }

  friend ostream &operator<<(ostream &os, const ModInt &rhs) {
    return os << rhs.val;
  }

  friend istream &operator>>(istream &is, ModInt &rhs) {
    ll x;
    is >> x;
    rhs = ModInt(x);
    return is;
  }
};

int N, X[SIZE];

ll calc(int len) {
  ModInt<mod> val = 0;

  for (int i = 0; i < len; i++) {
    val = val * 2 + X[i];
  }
  val++;

  bool ok = true;

  for (int i = len; i < N; i += len) {
    bool less = false;
    for (int j = 0; j < len; j++) {
      int x = i / len % 2 ? !X[j] : X[j];
      if (X[j + i] > x) {
        less = true;
        break;
      }
      if (X[j + i] < x) {
        ok = false;
        break;
      }
    }
    debug(less, ok);
    if (less) break;
    if (!ok) break;
  }

  if (ok) {
    return val.val;
  } else {
    return (val - 1).val;
  }
}

int main() {
  vector<int> divisors;
  ModInt<mod> nums[SIZE] = {};

  scanf("%d", &N);

  for (int i = 0; i < N; i++) scanf("%1d", X + i);

  for (int i = 1; i <= N; i++) {
    if (N % i == 0 && N / i % 2) {
      divisors.push_back(i);
    }
  }

  ModInt<mod> ans = 0;

  for (auto len : divisors) {
    ModInt<mod> res = calc(len);

    debug(res);

    res = nums[len] + res;
    ans += res * 2 * len;

    for (auto x : divisors) {
      if (x % len == 0) {
        nums[x] -= res;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6000