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

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

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