#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
unordered_map < int, int > P;
int main()
{   
    int n, m;
    scanf("%d %d", &n, &m);
    LL result = 0LL;
    int sum = 0;
    P[0] = 1;   
    for (int i = 0; i < n; ++i) {
        int a;
        scanf("%d", &a);
        sum = (sum + a) % m;
        result += 1LL * P[sum]++;
    }    
    printf("%lld", result);
    return 0;
}