#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main(){
  ll N, M;
  cin >> N >> M;
  map<ll, ll> mp;
  mp[0] = 1;
  ll ans = 0;
  ll sum = 0;
  for(int i=0;i<N;i++){
    ll a;
    cin >> a;
    sum += a;
    sum %= M;
    if(mp.find(sum) != mp.end()){
      ans += mp[sum];
      mp[sum]++;
    }else
      mp[sum] = 1;
  }
  cout << ans << endl;
  return 0;
}
