#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll N, M;
    cin >> N >> M;
    map<ll, ll> amari;
    amari[0] = 1;
    ll wa = 0;
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        ll A;
        cin >> A;
        wa = (wa + A) % M;
        ans += amari[wa];
        amari[wa]++;
    }
    cout << ans << endl;
    return 0;
}
