#include <iostream>

using namespace std;

#define uint unsigned int

uint N, M;
long long sum = 0;
void check(uint modsum[], uint allmod[]){
    for(int i = 0; i < N; i++){
        cout << modsum[i] << " ";
    }
    cout << "\n";
    //for(int i = 0; i < M; i++){
    //    cout << allmod[i] << " ";
    //}
    //cout << "\n";
    cout << sum << "\n" << endl;
}

int main(){
    cin >> N >> M;
    uint modsum[N] = {};
    uint allmod[M] = {};

    uint a;
    cin >> a;
    modsum[0] = a % M;
    if(modsum[0] == 0)
        sum++;
    allmod[modsum[0]]++;

    for(int i=1;i<N;i++){
       // check(modsum, allmod);
        cin >> a;
        //if((a % M) == 0)
        //    sum++;
        modsum[i] = (modsum[i-1] + (a % M)) % M;
        if(modsum[i] == 0)
            sum++;
        sum += allmod[modsum[i]];
        allmod[modsum[i]]++;
    }

    //check(modsum, allmod);

    cout << sum << endl;
    return 0;
}
