#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  Int ans=0,res=0;
  map<Int, Int> dp;
  dp[res]++;
  for(Int i=0;i<n;i++){
    res+=a[i];
    res%=m;
    ans+=dp[res];
    //cout<<a[i]<<":"<<res<<":"<<dp[res]<<endl;
    dp[res]++;
  }
  cout<<ans<<endl;
  return 0;
}
