import sys
MOD = 1000000007
n = 0
d = []


def read_input():
    global n
    global d
    n = int(input())
    d = list(map(int, input().split()))


def compute(dp, i, j, k):
    global d
    if dp[i][j][k] != -1:
        return dp[i][j][k]

    if i == 1:
        return 1 if k == 1 else 0

    dp[i][j][k] = 0

    if k>1:
        dp[i][j][k] = compute(dp, i-1, j, k-1) % MOD
        dp[i][j][k] %= MOD

    else:
        for x in range(6):
            if x == j:
                continue
            for l in range(1, d[x]+1):
                dp[i][j][k] += compute(dp, i-1, x, l)
                dp[i][j][k] %= MOD


    return dp[i][j][k]


def solve():
    global n
    global d
    dp = [[[-1 for _ in range(d[j]+1)] for j in range(6)] for _ in range(n+1)]
    ans = 0
    for j in range(6):
        for k in range(1,min(d[j]+1,n+1)):
            ans = (ans + compute(dp, n, j, k)) % MOD

    print(ans)

def main():
    sys.setrecursionlimit(10000)   
    read_input()
    solve()


if __name__ == "__main__":
    main()
