n = int(input()) S = list(input()) mod = 998244353 Open = [0 for _ in range(n)] Close = [0 for _ in range(n)] for i in range(n): if S[i] == '(': Open[i] += 1 else: Close[i] += 1 Open[i] += Open[i - 1] Close[i] += Close[i - 1] DP = [0 for _ in range(n + 1)] DP[0] = 1 for i in range(n): NDP = [0 for _ in range(n + 1)] dif = Open[i] - Close[i] if S[i] == '(': for j in range(i + 1): NDP[j + 1] += DP[j] NDP[j + 1] %= mod NDP[j] += DP[j] NDP[j] %= mod else: for j in range(i + 1): if j > 0: NDP[j - 1] += DP[j] NDP[j - 1] %= mod if dif - j >= 0: NDP[j] += DP[j] NDP[j] %= mod DP = NDP print(DP[0])