import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import gcd,log from math import sqrt, ceil from bisect import bisect_left, bisect_right from typing import Iterable input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) class SegmentTree: def __init__(self, init_val, segfunc, ide_ele): n = len(init_val) self.segfunc = segfunc self.ide_ele = ide_ele self.num = 1 << (n - 1).bit_length() self.tree = [ide_ele] * 2 * self.num self.size = n for i in range(n): self.tree[self.num + i] = init_val[i] for i in range(self.num - 1, 0, -1): self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1]) def update(self, k, x): k += self.num self.tree[k] = x while k > 1: k >>= 1 self.tree[k] = self.segfunc(self.tree[2*k], self.tree[2*k+1]) def query(self, l, r): if r==self.size: r = self.num res = self.ide_ele l += self.num r += self.num right = [] while l < r: if l & 1: res = self.segfunc(res, self.tree[l]) l += 1 if r & 1: right.append(self.tree[r-1]) l >>= 1 r >>= 1 for e in right[::-1]: res = self.segfunc(res,e) return res mod = 998244353 N = int(input()) S = input() S = S[::-1] res = 0 for k in range(N): dp = [0] * (N+1) imos = [0] * (N+1) dp[0] = 1 if k+1 <= N and S[k]=="1": imos[k+1] -= dp[0] imos[k+1] %= mod SUM = dp[0] for i in range(1,N+1): imos[i] += imos[i-1] imos[i] %= mod dp[i] = (SUM + imos[i]) dp[i] %= mod SUM = (SUM+dp[i]) % mod if i+k+1 <= N and S[i+k]=="1": imos[i+k+1] -= dp[i] imos[i+k+1] %= mod res += (pow(2,N-1,mod)-dp[N]) * pow(2,k,mod) res %= mod print(res)