#include <iostream>

using namespace std;

#define uint unsigned int

int main(){
    uint N, M;
    cin >> N >> M;
    long long sum = 0;
    uint modsum[N] = {};

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

    //for(int i = 0; i < N; i++){
    //    cout << modsum[i] << " ";
    //}
    //cout << "\n";

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