import sys
from collections import deque
import copy
import heapq
import math

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [long(input_raw[0]), long(input_raw[1])]
    A_list = []
    B_list = [0]
    input_raw = read_func().strip().split()
    for i in range(N):
        [A] = [long(input_raw[i])]
        A_list.append(A)
        B_list.append(A + B_list[i])

    mod_dic = {}
    for i in range(N + 1):
        B_mod = B_list[i] % M
        if B_mod not in mod_dic:
            mod_dic[B_mod] = 1
        else:
            mod_dic[B_mod] += 1

    count = 0
    for B_mod in mod_dic:
        n = mod_dic[B_mod]
        count += n*(n-1)/2

    print count


if __name__ == '__main__':
    main()
