n, x, MOD, f = gets.to_i, gets.chomp + '1', 998244353, [0]
n.times{|i| f << (f[-1]*2 + x[i].to_i) % MOD}
m, ans = Array.new(n,0), (f[n]+1) * 2*n
ha = Hash.new{|h,k| u = k; u += 1 while u < n && x[u-k] != x[u]; h[k] = f[k] + x[u].to_i}
(1..n).each{|i| t = i.gcd(n); (ans += (m[i] += ha[t]) * (i - 2*n); (i*2).step(n-1,i){|j| m[j] -= m[i]}) if i/t%2 == 0}
p ans % MOD