n = int(input()) mod = 998244353 ans = 1 count = 0 dp = [1] for v in input(): if v == "(": dp.append(dp[-1]) for i in range(len(dp)-2, 0, -1): dp[i] = (dp[i-1]+dp[i])%mod count += 1 else: for i in range(len(dp)-1): dp[i] = (dp[i]+dp[i+1])%mod dp.pop() count -= 1 if count == 0: ans = ans*dp[0]%mod dp = [1] print(ans)