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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n,m;
    cin>>n>>m;
    vector<ll> a(n+1);
    a[0]=0;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)a[i]=(a[i]+a[i-1])%m;
    sort(a.begin(),a.end());
    ll ans=0;
    int cnt=1;
    for(int i=0;i<n;i++){
        if(a[i]!=a[i+1]){
            ans+=(cnt*(cnt-1))/2;
            cnt=1;
        }
        else tmp++;
    }
    ans+=(cnt*(cnt-1))/2;
    cout<<ans<<endl;

}