if __name__ == '__main__':
    n, m = map(int, input().split())
    sweets = list(map(int, input().split()))

    cnt = 0
    total = 0
    totals = [0]
    for i in range(n):
        total += sweets[i]
        for old in totals:
            if (total - old) % m == 0:
                cnt += 1
        totals.append(total)
    
    print(cnt)