#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  ll m;
  cin>>n>>m;
  ll a[n+1]={};
  ll s[n+1]={};
  ll ans=0;
  cin>>a[0];
  s[0]=a[0]%m;
  if(s[0]%m==0) ans++;
  for(int i=1;i<n;i++){
    cin>>a[i];
    a[i]%=m;
    s[i]=s[i-1]+a[i];
    s[i]%=m;
    if(s[i]%m==0) ans++;
    //cout<<s[i]<<endl;
  }
  //cout<<ans<<endl;
  sort(s,s+n);
  //for(int i=0;i<n;i++) cout<<s[i]<<endl;
  int c=0;
  for(int i=1;i<n;i++){
    //cout<<s[i]<<" "<<s[i-1]<<endl;
    if(s[i]==s[i-1]) c++;
    else{
      ans=ans+c*(c+1)/2;
      //cout<<c<<endl;
      c=0;
      //cout<<s[i]<<" "<<ans<<endl;
    }
  }
  ans=ans+c*(c+1)/2;
  cout<<ans<<endl;
  return 0;
}
