#include<iostream>
#define DIM 200005
#define mod 998244353
using namespace std;
int n, i, sol, j, sum, ok;
char s[DIM], s2[DIM], ff[DIM];
int v[DIM];
int main(){
    cin>> n;
    cin>> s + 1;
    for(i = 1; i <= n; i++){
        if(n % i == 0 && (n / i) % 2 == 1){
            ff[i] = 1;
            sum = 0;
            for(j = 1; j <= i; j++){
                sum = (sum * 2 + s[j] - '0') % mod;
            }
            ok = 1;
            for(j = 1; j <= i; j++){
                s2[j] = s[j];
            }
            for(j = i + 1; j <= n; j++){
                s2[j] = '0' + '1' - s2[j - i];
            }
            for(j = 1; j <= n; j++){
                if(s2[j] != s[j]){
                    if(s2[j] < s[j]){
                        break;
                    }
                    else{
                        ok = 0;
                        break;
                    }
                }
            }
            sum = (sum + ok) % mod;
            v[i] = sum;
        }
    }
    for(i = 1; i <= n; i++){
        if(ff[i] == 0){
            continue;
        }
        for(j = i + i; j <= n; j += i){
            v[j] = (mod + v[j] - v[i]) % mod;
        }
        sol = (sol + v[i] * 2LL * i) % mod;
    }
    cout<< sol;
}
