// https://atcoder.jp/contests/agc039/tasks/agc039_c
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn rotate(mut a: Vec<char>) -> Vec<char> {
    let n = a.len();
    let tmp = a[n-1];
    for i in (1..n).rev() {
        a[i] = a[i-1];
    }
    a[0] = ifv!(tmp == '0', '1', '0');
    a
}

fn check(mut a: Vec<char>) -> usize {
    let mut b = a.clone();
    let mut cnt = 0;
    while true {
        a = rotate(a);
        cnt += 1;
        if a == b {
            return cnt
        }
    }
    0
}

const MOD: i64 = 998244353;

fn count_less(x: &Vec<char>) -> i64 {
    let n = x.len();
    let mut ret = 0;
    for i in 0..n {
        ret = ret * 2 + ifv!(x[i] == '1', 1, 0);
        ret %= MOD;
    }
    (ret + 1) % MOD
}

fn count_ptn(x: &Vec<char>, gl: usize) -> i64 {
    let mut dp = dvec!(0; gl+1, 2);
    dp[0][0] = 1;
    for idx in 0..gl {
        for f in 0..2 {
            let mut base = dp[idx][f];
            for c in 0..2 {
                let mut tf = f;
                if c == 0 && x[idx] == '1' {
                    tf = 1;
                }
                if f == 0 && x[idx] == '0' && c == 1 {
                    continue;
                }
                dp[idx+1][tf] += base;
                dp[idx+1][tf] %= MOD;
            }
        }
    }

    let n = x.len();
    let mut big = false;
    for i in 0..n {
        let c = i / gl;
        let mut wo = x[i%gl];
        if c % 2 == 1 {
            wo = ifv!(wo == '1', '0', '1');
        }
        if wo == '1' && x[i] == '0' {
            big = true;
            break;
        } else if wo == '0' && x[i] == '1' {
            break;
        }
    }

    (dp[gl][1] + ifv!(big, 0, 1)) % MOD
}

fn main() {
    input! {
        n: usize,
        x: chars
    };


    let mut wp = 1;
    {
        let mut n = n;
        while n % 2 == 0 {
            wp *= 2;
            n /= 2;
        }
    }
    let cnt = count_less(&x);


    let mut wset = vec![];
    for l in (1..(n+1)).rev() {
        if l % 2 == 0 {
            continue;
        }
        if n % l != 0 {
            continue;
        }

        let co = count_ptn(&x, n/l);
        wset.push(vec![l as i64, co]);
    }


    // debug!(wset);

    let mut special = 0;
    let mut wn = wset.len();
    for i in 0..wn {
        let mut dec = 0;
        for j in 0..i {
            if wset[j][0] % wset[i][0] == 0 {
                dec += wset[j][1];
                dec %= MOD;
            }
        }

        wset[i][1] = (wset[i][1] + MOD - dec) % MOD;
        let mut co = wset[i][1];
        let mut k = (n as i64)/wset[i][0];
        // debug!(co, dec, k);
        special += (k * 2) % MOD * co % MOD;
        special %= MOD;
    }

    println!("{}", special);
}


Measured memory_bytes: 14588