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