N, A = map(int, input().split())
X = list(map(int, input().split()))

dp = [[0 for _ in range(A)] for _ in range(N + 1)]  # dp[num][mod] = count
dp[0][0] = 1

for i in range(N):
    for mod in range(A):
        dp[i + 1][mod] += dp[i][mod]
        dp[i + 1][(mod + X[i]) % A] += dp[i][mod]

print(dp[N][0] - 1)