import sys input = sys.stdin.readline N=int(input()) S=input().strip() mod=998244353 SET=set() for i in range(N): if S[i]=="1": SET.add(i) ANS=0 for i in range(N): USED=[0]*(N+N+1) NOUSED=[0]*(N+N+1) NOUSED[0]=1 for j in range(N-1): USED[j+1]+=USED[j] NOUSED[j+1]+=NOUSED[j] if j-i in SET: USED[j+1]+=NOUSED[j-i]+USED[j] NOUSED[j+1]+=NOUSED[j]-NOUSED[j-i] else: USED[j+1]+=USED[j] NOUSED[j+1]+=NOUSED[j] USED[j+1]%=mod NOUSED[j+1]%=mod if N-1-i in SET: ANS+=pow(2,i,mod)*(USED[N-1]+NOUSED[N-1-i]) else: ANS+=pow(2,i,mod)*USED[N-1] ANS%=mod #print(ANS,USED,NOUSED) print(ANS%mod)