#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M, A;
  cin >> N >> M;
  map<long long, long long> mp;
  cin >> A;
  long long S = A;
  mp[S % M]++;
  for (long long i = (0); i < (N); i++) {
    cin >> A;
    S += A;
    mp[S % M]++;
  }
  long long sum = 0;
  map<long long, long long>::iterator itr;
  for (itr = mp.begin(); itr != mp.end(); itr++) {
    long long sec = itr->second;
    sum += sec * (sec - 1) / 2;
  }
  cout << fixed << sum << endl;
  return 0;
}
