import sys input = lambda : sys.stdin.readline().rstrip() write = lambda x: sys.stdout.write(x+"\n") debug = lambda x: sys.stderr.write(x+"\n") writef = lambda x: print("{:.12f}".format(x)) n = int(input()) p = list(map(int, input().split())) M = 10**9+7 inv2 = pow(2, M-2, M) dp = [1,0,0] # (0.5未満, 0.5, 0.5以上) for v in p: ndp = dp[:] if v<50: for i in range(3): ndp[i] += dp[i] ndp[i] %= M elif v>50: for i in range(3): ndp[2-i] += dp[i] ndp[2-i] %= M else: ndp[1] += sum(dp) ndp[1] %= M dp = ndp ans = dp[2] print(ans%M)