#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int A[N];
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  int B[N + 1];
  B[0] = 0;
  for (int i = 1; i < N + 1; ++i) {
    B[i] = (B[i - 1] + A[i - 1]) % M;
  }
  map<int, int> m;
  for (int i = 0; i < N + 1; ++i) {
    map<int, int>::iterator it = m.find(B[i]);
    if (it != m.end()) {
      m[B[i]]++;
    } else {
      m.insert(make_pair(B[i], 1));
    }
  }
  long ans = 0;
  for (map<int, int>::iterator it = m.begin(); it != m.end(); ++it) {
    ans += (it->second) * (it->second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
