n,k = map(int,input().split()) C = list(map(int,input().split())) l = [] for i,c in enumerate(C,1): for j in range(c): l.append(i) ten = [1] for i in range(n+1): ten.append(ten[-1]*10%k) dp = [[0]*k for i in range(1<> t & 1: continue dp[i|1<