#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
    int n,m; cin>>n>>m;
    vector <int> a(n);
    vector <int> SUM(n+1);
    for(int i=0;i<n;i++){
        cin>>a[i];
        SUM[i+1] += (a[i]+SUM[i])%m;
    }
    map <int,int> data;
    ll ans=0;
    for(int i=0;i<n+1;i++){
        ans += data[SUM[i]];
        data[SUM[i]]++;
    }
    cout<<ans<<endl;
}
