#include<bits/stdc++.h>
using namespace std;

uint_fast32_t N, M, a[101010], A;

int main(){
    scanf("%u%u", &N, &M);
    for(int i = 1; i <= N; ++i){
        scanf("%u", a + i);
        a[i] += a[i - 1];
        a[i] %= M;
    }
    sort(a, a + N + 1);
    for(int i = 0, j = 0; i <= N; ++i){
        if(i && a[i] != a[i - 1])j = 0;
        A += j++;
    }
    cout << A << endl;
    return 0;
}