#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

/// The definitions in this library are as below.
#define rI readInt
#define rL readLong
#define rC readChar
#define rC2 readChar2
#define rS readString

#define pb push_back

#define acc accumulate
namespace __library_79brue{
    /// This is a C++ library which improves the programming speed by \
        defining frequently used data structures or algorithms.       \
        This library can be freely used without any copyrights,       \
        but I recommend not to change the name of this library.       \
        Made by 79brue                                                \
        2019

    /// The functions or structures in this library are as below.
    /// quit()
    /// readInt() readLong() readChar() readChar2() readString()

    /// terminates the program
    inline void quit(){
        exit(0);
    }

    /// reads an integer
    inline void readInt(int& _x){
        scanf("%d", &_x);
    }

    /// reads a long-long integer
    inline void readLong(ll& _x){
        scanf("%lld", &_x);
    }

    /// reads a character
    inline void readChar(char& _x){
        scanf(" %c", &_x);
    }

    /// reads a character, the character may be space or line-break, etc...
    inline void readChar2(char &_x){
        scanf("%c", &_x);
    }

    inline void readString(char* _x){
        scanf("%s", _x);
    }
}
using namespace __library_79brue;

const ll MOD = 998244353;

ll n;
bool arr[200002];
vector<ll> cand;

ll pow2[200002]={1};
ll mcnt[200002];
ll ans;
ll cnt;

int main(){
    rL(n);
    for(ll i=1; i<=n; i++) scanf("%1d", &arr[i]);

    for(ll i=2; i<=n; i+=2){
        if(n%i==(i/2)) cand.push_back(i);
    }
    cand.push_back(n*2);

    for(ll i=1; i<=n; i++){
        pow2[i] = (pow2[i-1] * 2) % MOD;
    }

    ans = 2LL*n;
    for(ll i=1; i<=n; i++){
        if(arr[i]) ans += (pow2[n-i] * 2 * n) % MOD;
        ans %= MOD;
    }

    for(ll a=0; a<(ll)cand.size()-1; a++){
        ll x = cand[a];
        ll y = x/2;
        bool able = 1;
        cnt = 0;

        for(ll i=0; i<y; i++){
            if(arr[i+1] == 0) continue;
            ll tmp = pow2[y-i-1];
            ans += (tmp * x) % MOD;
            ans %= MOD;
            cnt += tmp;
            cnt %= MOD;
        }

        for(ll i=y+1; i<=n; i++){
            ll tmpn = (i-1)%y;
            bool tmp;
            if(((i-1)/y)%2 == 1){
                tmp = !arr[tmpn+1];
            }
            else{
                tmp = arr[tmpn+1];
            }

            if(arr[i] == 0 && tmp == 1){
                able = 0;
                break;
            }
            else if(arr[i] == 1 && tmp == 0){
                break;
            }
        }

        if(able){
            ans += x;
            ans %= MOD;
            cnt++;
            cnt %= MOD;
        }

        ans -= (mcnt[a] * x) % MOD;
        cnt -= mcnt[a];
        ans += 2*MOD, cnt += 2*MOD;
        ans %= MOD, cnt %= MOD;

        for(ll b=0; b<(ll)cand.size(); b++){
            ll tmp = cand[b];
            if(tmp > x && tmp%x == 0 && (tmp/x)%2 == 1){
                if(tmp==2*n){
                    ans -= (cnt * tmp) % MOD;
                    ans += 2LL*MOD;
                    ans %= MOD;
                }
                else{
                    mcnt[b] += cnt;
                    mcnt[b] %= MOD;
                }
            }
        }
    }

    printf("%lld", ans);
}


Measured memory_bytes: 2048