#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  long long M;
  cin >> N >> M;
  vector<int> box(M);
  vector<long long> A(0);
  A.push_back(0);
  for (long long i = 0; i < N; i++) {
    long long a;
    cin >> a;
    A.push_back(a);
  }
  long long ans = 0;
  for (long long i = 0; i < A.size(); i++) {
    if (i == 0) {
    } else {
      A[i] = A[i] + A[i - 1];
    }
  }
  for (long long i = 0; i < A.size(); i++) {
    long long index = A[i] % M;
    box[index] = box[index] + 1;
  }
  for (long long i = 0; i < M; i++) {
    long long cnt = box[i];
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
