N = 998244353

def calc_divisors(n)
  divisors = []
  root_n = Math.sqrt(n).to_i
  1.upto(root_n) do |k|
    if n % k == 0
      divisors << k
      divisors << n / k
    end
  end
  divisors
end

def get_int
  gets.chop.to_i
end

def get_ints
  gets.chop.split.map(&:to_i)
end

def get_double
  gets.chop.to_f
end

def get_str
  gets.chop
end

def get_strs
  gets.chop.split
end

def main
  n = get_int
  x_s = get_str
  x_i = x_s.to_i(2)
  ks = calc_ks(n)
  c = 0
  ans = 0
  ks.each do |k|
    s = x_s[0...k]
    s_rev = s.chars.map {|c| c == "0" ? "1" : "0" }.join
    s_n = s.to_i(2)
    y_s = s + (s_rev + s) * ((n/k - 1)/2)
    y_i = y_s.to_i(2)
    s_n += 1 if (y_i <= x_i)
    c += s_n
    ans += (2 * k) * s_n
    ans = ans % N
  end
  ans += (x_i%N + 1 - (c%N) + N) * (2 * n)
  ans = ans % N
  puts ans
end

def calc_ks(n)
  ks = []
  calc_divisors(n).each do |d|
    m = n / d
    if m >= 3 and m % 2 == 1
      ks << d
    end
  end
  ks
end

def calc_x_mod(x)
  m = 0
  x.each_with_index do |b, i|
    next if b == 0
    l = 1
    i.times do
      l = l * 2
      l = l % N
    end
    m += l
    m = m % N
  end
  m
end

if __FILE__ == $0
  main
end
