program division_by_two_with_something
  implicit none
  integer(8), parameter :: md = 998244353_8
  integer :: n, i, j, k, w, x(200000) = 0, s(200000)
  character(200000) :: tmp
  integer(8) :: a(200000) = 0_8, ans = 0_8, pow(0:200000) = 0_8
  logical :: ok
  pow(0) = 1_8
  read(*,*) n
  read(*,*) tmp
  do i = 1, n
    pow(i) = mod(2_8*pow(i-1),md)
    x(i) = ichar(tmp(i:i))-48
    ans = mod(2_8*ans+int(x(i),8),md)
  end do
  ans = mod((ans+1_8)*int(2*n,8),md)
  do i = n-1, 1, -1
    if (mod(n,i) /= 0 .or. mod(n/i,2) == 0) cycle
    s = 0
    do j = 1, i
      w = x(j)
      if (w == 1) a(i) = mod(a(i)+pow(i-j),md)
      do k = j, n, i
        s(k) = w
        w = xor(w,1)
      end do
    end do
    ok = .true.
    do j = 1, n
      if (s(j) /= x(j)) then
        ok = s(j) < x(j)
        exit
      end if
    end do
    if (ok) a(i) = mod(a(i)+1_8,md)
  end do
  do i = 1, n-1
    if (mod(n,i) /= 0 .or. mod(n/i,2) == 0) cycle
    ans = modulo(ans-int(2*(n-i),8)*a(i),md)
    do j = 2*i, n-1, i
      a(j) = modulo(a(j)-a(i),md)
    end do
  end do
  write(*,'(i0)') ans
end program division_by_two_with_something