#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int gcd(int a, int b) {
	while (a && b) {
		if (a > b) a %= b;
		else b %= a;
	}
	return a + b;
}
#define MOD 998244353

template<int mod>
struct ModInt{
    int x;
    ModInt():x(0){}
    ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
    ModInt &operator+=(const ModInt &p){
        if((x+=p.x)>=mod)x-=mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p){
        if((x+=mod-p.x)>=mod)x-=mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p){
        x=(int)(1LL*x*p.x%mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p){
        *this*=p.inverse();
        return *this;
    }
	ModInt &operator^=(long long p){
		ModInt res = 1;
		for (; p; p >>= 1) {
			if (p & 1) res *= *this;
			*this *= *this;
		}
		return *this = res;
	}
    ModInt operator-()const{return ModInt(-x);}
    ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
    ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
    ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
    ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
	ModInt operator^(long long p)const{return ModInt(*this)^=p;}
    bool operator==(const ModInt &p)const{return x==p.x;}
    bool operator!=(const ModInt &p)const{return x!=p.x;}
    explicit operator int() const { return x; }                           // added by QCFium
    ModInt operator=(const int p) {x = p; return ModInt(*this);} // added by QCFium
    ModInt inverse()const{
        int a=x,b=mod,u=1,v=0,t;
        while(b>0){
            t=a/b;
            a-=t*b;
            std::swap(a,b);
            u-=t*v;
            std::swap(u,v);
        }
        return ModInt(u);
    }
    friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
        return os<<p.x;
    }
    friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
        long long x;
        is>>x;
        a=ModInt<mod>(x);
        return (is);
    }
};
typedef ModInt<MOD> mint;


int main() {
	int n = ri();
	std::string _;
	std::cin >> _;
	std::vector<int> a;
	for (int i = 0; i < n; i++) a.push_back(_[i] - '0');
	
	std::vector<int> yaku;
	int tmp = n;
	while (!(tmp & 1)) tmp >>= 1;
	for (int i = 1; i <= tmp; i += 2) {
		if (tmp % i == 0) {
			yaku.push_back(i);
		}
	}
	if (tmp > 1) yaku.push_back(tmp);
	
	int sz = yaku.size();
	std::vector<mint> num(n + 1);
	for (int i = 0; i < sz; i++) {
		mint cur = 0;
		int k = yaku[i];
		int shu = n / k;
		std::vector<int> head(shu);
		for (int j = 0; j < shu; j++) head[j] = a[j];
		for (int j = 0; j < shu; j++)
			if (head[j]) cur += mint(2) ^ (shu - j - 1);
		// confirm
		bool ok = true;
		for (int j = 0; j < n; j++) {
			int real = head[j % shu];
			int head = a[j];
			if (j / shu & 1) real ^= 1;
			if (head != real) {
				ok = real < head;
				break;
			}
		}
		cur += ok;
		num[k] = cur;
	}
	for (int i = n; i; i--)
		for (int j = i * 2; j <= n; j += i) num[i] -= num[j];
	mint res = 0;
	for (int i = 1; i <= n; i++) {
		mint base = (2 * n / i);
		res += num[i] * base;
	}
	std::cout << res << std::endl;
	
	return 0;
}


Measured memory_bytes: 2936