#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int64 n,m;
  cin>>n>>m;
  int64 ans=0,a[n],sum[n];
  rep(i,n){
    cin>>a[i];
  }
  sum[0]=a[0]%m;
  rep1(i,n){
    sum[i]=(a[i]+sum[i-1])%m;
  }
  map<int64,int64> mp;
  mp[0]++;
  rep(i,n){
    mp[sum[i]]++;
  }
  for(auto p:mp){
    ans+=p.second()*(p.second()-1)/2;
  }
  cout<<ans;
}