def f(n, k): return n * K + k N, K = map(int, input().split()) C = list(map(int, input().split())) D = [] for i in range(9): D.extend([i + 1] * C[i]) N2 = 1 << N dp = [0] * (N2 * K) dp[0] = 1 for s in range(N2): for j in range(N): if (s >> j) & 1: continue if j and (s >> (j - 1)) & 1 == 0 and (D[j - 1] == D[j]): continue for k in range(K): dp[f(s|(1<