#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

template<long long mod>
class modint{
	public:
		long long x;
		modint(long long a){x=a%mod;if(x<0)x+=mod;}
		modint(){x=0;}

		modint pow(long long a){
			modint res(1), b(x);
			while(a){
				if(a&1)res*=b;
				b*=b;
				a>>=1;
			}
			return res;
		}

		modint inv(){return pow(mod-2);}

		modint& operator+=(modint a){x=(x+a.x)%mod;return *this;}
		modint& operator-=(modint a){x=x-a.x;if(x<0)x+=mod;return *this;}
		modint& operator*=(modint a){x=x*a.x%mod;return *this;}
		modint& operator/=(modint a){x=x*a.inv().x%mod;return *this;}

		modint operator+(modint a){return modint(x)+=a;}
		modint operator-(modint a){return modint(x)-=a;}
		modint operator*(modint a){return modint(x)*=a;}
		modint operator/(modint a){return modint(x)/=a;}

		modint operator-(){return modint(x);}

		bool operator==(const modint a){return x == a.x;}
		bool operator<(const modint a){return x < a.x;}
		bool operator>(const modint a){return x > a.x;}
};

template<long long mod>
ostream& operator<<(ostream& os, const modint<mod>& a){
	os << a.x;
	return os;
}
using mint = modint<998244353>;

bool was_output = false;
template<class t>
void output(t x){
	if(was_output)cout << " ";
	was_output = true;
	cout << x;
}

void outendl(){
	was_output = false;
	cout << endl;
}


vvector<mint> dp;
ll n;
string x;

string getrev(string str){
	string res = "";
	foreach(i, str)res+=(i=='1')?'0':'1';
	return res;
}


bool can(int len){
	string str = "";
	string add = x.substr(0, len);
	rep(i, n/len){
		str += add;
		add = getrev(add);
	}
	return str <= x;
};

string read(){
	string res = "";
	char d;
	while(scanf(" %c", &d)!=EOF)res+=d;
	return res;
}

int main(){
	scanf("%lld", &n);
	x = read();
	mint ans(0);
	mint sum(0);
	foreach(i, x){
		sum *= mint(2);
		if(i=='1'){
			sum += mint(1);
		}
	}
	sum += mint(1);
	//dp[i][j] j==1 上限 j==0 それ以外
	dp.resize(n, vector<mint>(2, mint(0)));
	if(x[0]=='1'){
		dp[0][1] = mint(1);
		dp[0][0] = mint(1);
	}else{
		dp[0][1] = mint(1);
	}
	rep(i, n-1){
		dp[i+1][0] += dp[i][0] * mint(2);
		if(x[i+1]=='1'){
			dp[i+1][1] += dp[i][1];
			dp[i+1][0] += dp[i][1];
		}else{
			dp[i+1][1] += dp[i][1];
		}
	}


	repa(i, n/2+1){
		if(n%i==0){
			if((n/i)%2==0)continue;
			for(int j=i*2;j<n;j+=i){
				dp[j-1][0] -= dp[i-1][0];
			}
			sum -= dp[i-1][0];
			ans += mint(i*2) * dp[i-1][0];
			string strs = x.substr(0, i);
			string addnor = x.substr(0, i);
			string addrev = getrev(addnor);
			if(can(i)&&dp[i-1][1].x!=0){
				bool flag = true;
				int count = 0;
				for(int j=i*2;j<n;j+=i){
					++count;
					strs += (count&1)?addrev:addnor;
					if(flag&&x.substr(0, j)==strs){
						dp[j-1][1] -= dp[i-1][1];
					}else{
						dp[j-1][0] -= dp[i-1][1];
						flag = false;
					}
				}
				sum -= dp[i-1][1];
				ans += mint(i*2) * dp[i-1][1];
			}
		}
	}

	ans += sum * mint(n * 2);
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 12136