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