#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::pair;
using std::swap;
using std::sort;
using std::lower_bound;
using std::unique;

using int64 = long long int;
using pii   = pair<int, int>;
using pii64 = pair<int64, int64>;

const int NIL = -1;

void init_IO() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}

namespace stupid {
	const int N = 3;

	int go(int value) {
		if(value & 1) {
			return (value - 1) / 2;
		} else {
			return value / 2 + (1 << (N - 1));
		}
	}

	void print() {
		vector<int> used(1 << N, 0);

		for(int j = 0; j < (1 << N); ++j) {
			if(used[j])
				continue;

			for(int v = j; used[v] == 0; v = go(v)) {
				cout << v << ' ';
				used[v] = 1;
			}

			cout << '\n';
		}
	}
};

const int MOD = 998244353;

inline int add(int x, int y) {
	return (x + y >= MOD ? x + y - MOD : x + y);
}

inline int sub(int x, int y) {
	return (x - y < 0 ? x - y + MOD : x - y);
}

inline int mult(int x, int y) {
	return (x * 1LL * y) % MOD;
}

const int MAX_N = (int)2e5 + 7777;
const int MAX_V = 2 * MAX_N;
const int MAX_PERIOD = 2 * MAX_N;

int n;
string x;

int used[MAX_V], mark = 1337;
int color[MAX_V], touched[MAX_V];
int bi;

int which_cc[MAX_V], swch[MAX_V];

int deque_get(int);

void dfs(int v, int c, int fst) {
	used[v] = mark;
	color[v] = c;
	which_cc[v] = fst;

	int u = deque_get(v);

	if(u > 0) {
		--u;

		if(used[u] != mark) {
			dfs(u, c, fst);
		} else {
			if(color[u] != color[v])
				bi = 0;
		}
	} else {
		u = -u;
		--u;

		if(used[u] != mark) {
			dfs(u, c ^ 1, fst);
		} else {
			if(color[u] == color[v])
				bi = 0;
		}
	}
}

int count[MAX_PERIOD];
int pow2[MAX_PERIOD];

void precalc() {
	pow2[0] = 1;

	for(int i = 1; i < MAX_PERIOD; ++i) {
		pow2[i] = add(pow2[i - 1], pow2[i - 1]);
	}
}

int deque[MAX_V];
int l, r;

inline void deque_push_front(int value) {
	int p = --l;

	if(p < 0)
		p += MAX_V;

	deque[p] = value;

	if(l < 0)
		l += MAX_V;
}

inline int deque_pop_back() {
	int p = --r;

	if(p < 0)
		p += MAX_V;

	int rez = deque[p];

	if(r < 0)
		r += MAX_V;

	return rez;
}

inline int deque_get(int i) {
	int pos = l + i;

	if(pos >= MAX_V)
		pos -= MAX_V;

	return deque[pos];
}

void solve() {
	cin >> n >> x;
	vector<int> divs;

	for(int i = 1; i <= 2 * n; ++i) {
		if((2 * n) % i == 0)
			divs.push_back(i);
	}

	int answ = 0;

	for(auto& cycle_size: divs) {
		int to_clear = n;

		memset(touched, 0, sizeof(touched[0]) * to_clear);
		memset(swch, 0, sizeof(swch[0]) * to_clear);

		l = r = 0;

		for(int i = n - 1; i >= 0; --i) {
			deque_push_front(i + 1);
		}

		for(int i = 0; i < cycle_size; ++i) {
			int lst = deque_pop_back();
			deque_push_front(-lst);
		}

		bi = 1;
		++mark;

		int fst = 0;

		for(int v = 0; v < n; ++v) {
			if(used[v] != mark) {
				dfs(v, 0, fst);
				++fst;
			}

			if(bi == 0)
				break;
		}

		if(bi == 0)
			continue;

		//DBG(cycle_size); DBG(fst);
		int cur = fst;
		int fl = 1;

		for(int i = 0; i < n; ++i) {
			int value = x[i] - '0';
			color[i] ^= swch[which_cc[i]];

			if(touched[which_cc[i]] == 0) {
				--cur;
				touched[which_cc[i]] = 1;

				if(value == 1)
					count[cycle_size] = add(count[cycle_size], pow2[cur]);

				if(color[i] != value) {
					swch[which_cc[i]] = 1;
				}
			} else {
				if(color[i] > value) {
					fl = 0;
					break;
				} else if(color[i] < value) {
					count[cycle_size] = add(count[cycle_size], pow2[cur]);
					fl = 0;
					break;
				}
			}
		}

		count[cycle_size] = add(count[cycle_size], fl);
		//DBG(count[cycle_size]);
	}

	//DBG("----");

	for(auto& i: divs) {
		for(auto& j: divs) {
			if(i % j != 0 || j == i)
				continue;

			count[i] = sub(count[i], count[j]);
		}
	}

	/*for(int cycle_size = 1; cycle_size <= 2 * n; ++cycle_size) {
		DBG(cycle_size); DBG(count[cycle_size]);
	}*/

	for(int i = 1; i <= 2 * n; ++i) {
		answ = add(answ, mult(count[i], i));
	}

	cout << answ << '\n';
}

int main() {
	init_IO();

	//stupid::print();
	precalc();
	solve();

	return 0;
}


Measured memory_bytes: 12880