#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unsigned long long int ull;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
const ll MOD=1e9+7;


int main(){
    int N,M;cin>>N>>M;
    vector<ll> A(N),S(N+1,0);
    map<int,ll> mp;
    mp[0]++;
    for(int i=0;i<N;++i) cin>>A[i];
    for(int i=0;i<N;++i){
        S[i+1]=S[i]+A[i];
        S[i+1]%=M;
        mp[S[i+1]]++;
    }
    ll ans=0;
    for(auto it:mp){
        ans+=(it.second)*(it.second-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N,M;cin>>N>>M;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  vector<int64_t>B(N+1);B.at(0)=0;
  for(int i=1;i<=N;i++)
    B.at(i)=(B.at(i-1)+A.at(i-1))%M;
  map<int64_t,int64_t>m;
  for(int i=0;i<=N;i++)
    if(m.count(B.at(i)))
       m.at(B.at(i))++;
       else
       m[B.at(i)]=1;
       int64_t ans=0;
       for(auto p:m){
       auto v=p.second;
         ans+=(v*(v-1))/2;
       }cout<<ans<<endl;
  return 0;
}
