#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> S(M);
  for (int i = 0; i < M; i++) S[i] = 0;
  int64_t last = 0;
  S[0]++;
  for (int i = 0; i < N; i++) {
    int64_t tmp;
    cin >> tmp;
    S[(last + tmp) % M]++;
    last = (last + tmp) % M;
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    ans += S[i] * (S[i] - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
