#include <bits/stdc++.h>
using namespace std;
long long kai(long long k) {
  if (k == 0)
    return 1;
  else
    return k * kai(k - 1);
}
long long com(int a) {
  long long c;
  c = (kai(a) / kai(a - 2)) / 2.0;
  return c;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> V(n + 1);
  vector<long long> A(n);
  long long cnt = 0;
  for (int i = 0; i < A.size(); i++) {
    cin >> A[i];
  }
  V[0] = 0;
  for (int i = 0; i < A.size(); i++) {
    V[i + 1] = V[i] + A[i];
  }
  map<int, int> M;
  for (int i = 0; i < V.size(); i++) {
    M[V[i] % m]++;
  }
  for (auto v : M) {
    if (v.second >= 2) cnt += com(v.second);
  }
  cout << cnt << endl;
  return 0;
}
