### BUGGY CODE ###

import math

N = int(input())
X = input()
mod = 998244353


def calc_div_odd(N):
    div_odd = []
    for i in range(1, math.floor(N ** (1/2)) + 1):
        if N % i == 0:
            if i % 2 == 1:
                div_odd.append(i)
            if N // i != i:
                if (N // i) % 2 == 1:
                    div_odd.append(N//i)
    return div_odd


block_num_list = calc_div_odd(N)
block_num_list.sort()
ok_num = {x: 0 for x in block_num_list}
use_num = {x: 0 for x in block_num_list}
div_dict = {x: [] for x in block_num_list}
for block_num in block_num_list:
    block_len = N // block_num
    X_ref = X[:block_len]
    ok_num[block_num] += int(X_ref, 2) % mod
    X_ref_inv = ''
    for i in range(block_len):
        x = '0' if X_ref[i] == '1' else '1'
        X_ref_inv += x
    Y = (X_ref + X_ref_inv) * (block_num // 2) + X_ref
    flg = 1
    for x, y in zip(X, Y):
        if x == '1' and y == '0':
            break
        elif x == '0' and y == '1':
            flg = 0
            break
    if flg:
        ok_num[block_num] += 1

    # if int(X, 2) >= int((X_ref + X_ref_inv) * (block_num // 2) + X_ref, 2):
        # ok_num[block_num] += 1

    div_d_list = calc_div_odd(block_num)
    for div_d in div_d_list:
        if div_d != block_num:
            div_dict[block_num].append(div_d)

ans = 0
for block_num in reversed(block_num_list):
    block_len = N // block_num
    div_list = div_dict[block_num]
    use_num[block_num] += ok_num[block_num]
    for div in div_list:
        use_num[div] -= use_num[block_num]
    ans = (ans + ((block_len * 2) * use_num[block_num])) % mod

print(ans)


### FIXED CODE ###

import math
import sys
input = sys.stdin.readline

N = int(input())
X = input()
mod = 998244353


def calc_div_odd(N):
    div_odd = []
    for i in range(1, math.floor(N ** (1/2)) + 1):
        if N % i == 0:
            if i % 2 == 1:
                div_odd.append(i)
            if N // i != i:
                if (N // i) % 2 == 1:
                    div_odd.append(N//i)
    return div_odd


def main():
    block_num_list = calc_div_odd(N)
    block_num_list.sort()
    ok_num = {x: 0 for x in block_num_list}
    use_num = {x: 0 for x in block_num_list}
    div_dict = {x: [] for x in block_num_list}
    for block_num in block_num_list:
        block_len = N // block_num
        X_ref = X[:block_len]
        ok_num[block_num] += int(X_ref, 2) % mod
        X_ref_inv = ''
        for i in range(block_len):
            x = '0' if X_ref[i] == '1' else '1'
            X_ref_inv += x
        Y = (X_ref + X_ref_inv) * (block_num // 2) + X_ref
        flg = 1
        for x, y in zip(X, Y):
            if x == '1' and y == '0':
                break
            elif x == '0' and y == '1':
                flg = 0
                break
        if flg:
            ok_num[block_num] += 1

        # if int(X, 2) >= int((X_ref + X_ref_inv) * (block_num // 2) + X_ref, 2):
            # ok_num[block_num] += 1

        div_d_list = calc_div_odd(block_num)
        for div_d in div_d_list:
            if div_d != block_num:
                div_dict[block_num].append(div_d)

    ans = 0
    for block_num in reversed(block_num_list):
        block_len = N // block_num
        div_list = div_dict[block_num]
        use_num[block_num] = (use_num[block_num] + ok_num[block_num]) % mod
        for div in div_list:
            use_num[div] = (use_num[div] - use_num[block_num]) % mod
        ans = (ans + ((block_len * 2) * use_num[block_num])) % mod

    print(ans)


if __name__ == '__main__':
    main()