from collections import defaultdict

def main():
    num, person_num = map(int, input().split())
    data = list(map(int, input().split()))

    dp = [defaultdict(int) for i in range(num)]
    dp[0][data[0] % person_num] += 1

    ans = 0
    for i in range(1, num):
        now_data = data[i]
        ans += dp[i - 1][0]
        for key in dp[i - 1].keys():
            now_ind = (key + now_data) % person_num
            dp[i][now_ind] += dp[i - 1][key]
        dp[i][now_data % person_num] += 1

    ans += dp[num - 1][0]

    print(ans)

if __name__ == '__main__':
    main()
