#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

string Shift(string s, int loop, int num) {
	if (!num)return s;
	if (num < loop / 2) {
		string ret;
		for (int i = num; i < s.size(); i++)ret.push_back(s[i]);
		for(int i=0;i<num;i++)ret.push_back('1');
		return ret;
	}
	else {
		string ret;
		num -= loop / 2 - 1;
		for (int i = 0; i < num; i++)ret.push_back('1');
		for (int i = 0; i < s.size() - num; i++)ret.push_back(s[i]);
		return ret;
	}
}

long long int lcm(long long int a, long long int b) {
	long long int ret = a * b;
	while (b) {
		a %= b;
		swap(a, b);
	}
	ret /= a;
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	//cout << a << " " << b << endl;
	cin >> N;
	string s;
	cin >> s;
	/*
	if (N == 1) {
		if (s == "0")cout << 2 << endl;
		else cout << 4 << endl;
		return 0;
	}
	*/
	/*
	for (int i = 0; i < 1 << N; i++) {
		int num = i;
		//cout << i << endl;
		int step = 0;
		do {
			for (int j = N - 1; j >= 0; j--) {
			//	if ((num >> j) & 1)cout << 1;
			//	else cout << 0;
			}
			//cout << endl;
			if (num & 1) {
				num--;
				num >>= 1;
			}
			else {
				num >>= 1;
				num += 1 << (N - 1);
			}
			step++;
		} while (num != i);
		if (step != N * 2) {
			cout << i << " " << step << endl;
			cout << i % 993 << " " << i % 3641 << endl;
			for (int j = N - 1; j >= 0; j--) {
				if ((i >> j) & 1)cout << 1;
				else cout << 0;
			}
			cout << endl;
		}
	}
	*/

	long long int ans = 0;
	long long int by = 1;
	for (int i = s.size() - 1; i >= 0; i--) {
		if (s[i] == '1') {
			ans += by * N * 2;
			ans %= MOD;
		}
		by *= 2;
		by %= MOD;
	}
	ans += N * 2;
	ans %= MOD;
	//cout << ans << endl;
	vector<int>div;
	vector<long long int>num;
	for (int i = 3; i <= N; i += 2) {
		if (N % i)continue;
		string t;
		for (int j = 0; j < i; j++) {
			for (int k = 0; k < N / i; k++) {
				if (j & 1) {
					if (s[k] == '1')t.push_back('0');
					else t.push_back('1');
				}
				else {
					if (s[k] == '1')t.push_back('1');
					else t.push_back('0');
				}
			}
		}
		div.push_back(i);
		by = 1;
		long long int ret = 0;
		for (int j = N / i - 1; j >= 0; j--) {
			if (s[j] == '1')ret += by;
			by <<= 1;
			by %= MOD;
		}
		ret++;
		ret %= MOD;
		if (t > s)ret += MOD - 1;
		ret %= MOD;
		num.push_back(ret);
	}
	for (int i = num.size() - 1; i >= 0; i--) {
		set<long long int>st;
		for (int j = i + 1; j < num.size(); j++) {
			st.insert(lcm(div[i], div[j]));
		}
		for (int j = i + 1; j < num.size(); j++) {
			if (st.find(div[j]) != st.end()) {
				num[i] += MOD - num[j];
				num[i] %= MOD;
			}
		}
		long long int minus = 2 * N - 2 * (N / div[i]);
		minus *= num[i];
		minus %= MOD;
		ans += MOD - minus;
		ans %= MOD;
	}
	cout << ans << endl;

}


Measured memory_bytes: 972