#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
#define ll long long
using namespace std;

int main() {
  ll n, m;
  cin>>n>>m;
  vector<ll> A(n);
  rep(i, n) cin>>A[i];

  map<ll, ll> C;
  C[0]++;
  ll tmp=0;
  rep(i, n) {
    tmp+=A[i];
    C[tmp%m]++;
  }
  ll ans=0;
  for (auto i : C) {
    ll x=i.second;
    ans+=x*(x-1)/2;
  }
  cout<<ans<<endl;
  return 0;
}