#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(998244353)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}


const int n_max = 200005;
int n;
string x;

bool solve(int m){
    int hajime = m;
    int guuki = 1;
    while(hajime < n){
        if(guuki == 1){
            REP(i,m){
                if(x[i] == '0' and x[hajime + i] == '0'){
                    return false;
                }
                if(x[i] == '1' and x[hajime + i] == '1') return true;
            }
        }
        else{
            REP(i,m){
                if(x[i] == '0' and x[hajime + i] == '1'){
                    return true;
                }
                if(x[i] == '1' and x[hajime + i] == '0') return false;
            }
        }
        guuki = 1 - guuki;
        hajime += m;
    }
    return true;
}


signed main(){
    cin >> n >> x;


    int beki[n_max];
    beki[0] = 1;
    FOR(i,1,n+2){
        beki[i] = beki[i-1] * 2;
        beki[i] %= MOD;
    }
    int kake = 0;
    REP(i,n){
        if(x[n-1-i] == '1') kake += beki[i];
        kake %= MOD;
    }
    kake += 1;
    kake %= MOD;
    int ans = 2 * n;
    ans *= kake;
    ans %= MOD;

    int kosus[n_max] = {};







    FOR(i,1,n){
        if(2 * i > n) break;
        if(n %i != 0) continue;
        if( (n / i) %2 ==0 ) continue;

        int kosu = 0;
        int now = 1;
        int id = i - 1;
        
        while(id >= 0){
            if(x[id] == '1') kosu += now;
            kosu %= MOD;
            now *= 2;
            now %= MOD;
            id --;
        }


        
        int tmp = kosu;
        kosu += 1;
        if(solve(i) == false){
            kosu += MOD;
            kosu -= 1;
            kosu %= MOD;
        }



        int yakusuu = 1;
        while(yakusuu * yakusuu <= i){
            if(i % yakusuu != 0 ){
                yakusuu ++;
                continue;
            }
            kosu += MOD;
            kosu -= kosus[yakusuu];
            kosu %= MOD;
            if(i / yakusuu != yakusuu){
                kosu += MOD;
                kosu -= kosus[i/yakusuu];
                kosu %= MOD;
            }
            yakusuu += 1;
        }
        

        kosus[i] = kosu;
        int mainasu = kosu * 2 * n % MOD;
        ans += MOD  - mainasu;
        ans %= MOD;
        ans += 2 * i * kosu;
        ans %= MOD;
    }

    cout << ans << endl;

}

Measured memory_bytes: 3716