# -*- coding: utf-8 -*-

def main():
    n, m = map(int, input().split())
    a = [int(x) for x in input().split()]

    count = 0
    memo_index = []
    for start_point in range(0, n):
        if start_point not in memo_index:
            subcount = 0
            points = 0
            s = 0
            for i in range(start_point, n):
                s = s + a[i]
                if s % m == 0:
                    points = points + 1
                    subcount = subcount + points
                    memo_index.append(i + 1)
            count = count + subcount

    print(count)


if __name__ == '__main__':
    main()
