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

uint_fast32_t N, M, a[101010], A;
unordered_map<uint_fast32_t, uint_fast32_t> m;

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