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

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

int main(){
    cin >> N >> M;
    m[0] = 1;
    for(int i = 1; i <= N; ++i){
        cin >> a[i];
        a[i] += a[i - 1];
        a[i] %= M;
        A += m[a[i]]++;
    }
    cout << A << endl;
    return 0;
}
