#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 998244353;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

template<int MOD>
struct ModInt {
	static const int kMod = MOD;
	unsigned x;
	ModInt() :x(0) {}
	ModInt(signed x_) { x_ %= MOD; if (x_ < 0)x_ += MOD; x = x_; }
	ModInt(signed long long x_) { x_ %= MOD; if (x_ < 0)x_ += MOD; x = x_; }
	int get()const { return (int)x; }
	ModInt &operator+=(ModInt m) { if ((x += m.x) >= MOD)x -= MOD; return *this; }
	ModInt &operator-=(ModInt m) { if ((x += MOD - m.x) >= MOD)x -= MOD; return *this; }
	ModInt &operator*=(ModInt m) { x = (unsigned long long)x*m.x%MOD; return *this; }
	ModInt &operator/=(ModInt m) { return *this *= m.inverse(); }
	ModInt operator+(ModInt m)const { return ModInt(*this) += m; }
	ModInt operator-(ModInt m)const { return ModInt(*this) -= m; }
	ModInt operator*(ModInt m)const { return ModInt(*this) *= m; }
	ModInt operator/(ModInt m)const { return ModInt(*this) /= m; }
	ModInt operator-()const { return ModInt(MOD - (signed)x); }
	bool operator==(ModInt m)const { return x == m.x; }
	bool operator!=(ModInt m)const { return x != m.x; }
	ModInt inverse()const {
		signed a = x, b = MOD, u = 1, v = 0;
		while (b) {
			signed t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		if (u < 0)u += MOD;
		return ModInt(u);
	}
};
template<int MOD>
ostream &operator<<(ostream &os, const ModInt<MOD> &m) { return os << m.x; }
template<int MOD>
istream &operator>>(istream &is, ModInt<MOD> &m) { signed long long s; is >> s; m = ModInt<MOD>(s); return is; };

template<int MOD>
ModInt<MOD> pow(ModInt<MOD> a, unsigned long long k) {
	ModInt<MOD> r = 1;
	while (k) {
		if (k & 1)r *= a;
		a *= a;
		k >>= 1;
	}
	return r;
}

using mint = ModInt<MOD>;

vector<mint> powerArray(mint p, int n) {
	vector<mint> power(n + 1); power[0] = 1;
	for (int i = 0; i < n; i++)
		power[i + 1] = power[i] * p;
	return power;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	string X; cin >> X;

	string RX;
	
	for (int i = 0; i < N; i++) {
		if (X[i] == '0') RX += '1';
		else RX += '0';
	}
	string S = X + RX;
	dump(S);

	mint ans = 0;
	
	vector<mint> cnt(2 * N + 1, 0);

	vector<mint> pow2 = powerArray(2, 2 * N);

	vector<int> check(2 * N + 1, 0);

	// k is the cycle length
	for (int k = 1; k <= 2 * N; k++) {
		if (2 * N%k != 0) continue;
		if (k % 2 == 1) continue;
		if ((2 * N / k) % 2 == 0) continue;
		check[k] = true;
		int n = k / 2;
		dump(k, n);
		
		string t = X.substr(0, n);
		string rt;
		for (int i = 0; i < n; i++) {
			if (t[i] == '0') rt += '1';
			else rt += '0';
		}
		dump(t, rt);

		// tより小さい数の数え上げ
		// 10100: 0xxxx, 100xx
		rrep(i, 0, n) {
			if (t[i] == '1')
				cnt[k] += pow2[n - 1 - i];
		}
		
		// 先頭が t であるとき、X以下であるかどうか
		string T;
		rep(i, 0, N / n) {
			if (i % 2)
				T += rt;
			else
				T += t;
		}
		dump(X, T);
		if (T <= X)
			cnt[k] += 1;
	}
	dump(cnt);
	for (int i = 1; i <= 2 * N; i++) {
		for (int j = 2 * i; j <= 2 * N; j += i) {
			if (!check[j]) continue;
			cnt[j] -= cnt[i];
		}
	}

	dump(cnt);
	for (int k = 1; k <= 2 * N; k++) {
		ans += cnt[k] * k;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8008