N=int(input()) S=input() mod=998244353 cnt=0 dp=[1] for s in S: prev=dp prev_cnt=cnt cnt=prev_cnt+(s=="(")*2-1 dp=[0]*(cnt+1) for c in range(prev_cnt+1): if s=="(": dp[c+1]+=prev[c] dp[c+1]%=mod dp[c]+=prev[c] dp[c]%=mod else: if c: dp[c-1]+=prev[c] dp[c-1]%=mod if c