#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long n, m, ai, a;
  cin >> n >> m;
  long long mod[m + 10];
  for (long long i = 0; i < m + 1; ++i) {
    mod[i] = 0;
  }
  cin >> a;
  mod[a % m]++;
  for (long long i = 1; i < n; ++i) {
    cin >> ai;
    a += ai;
    mod[a % m]++;
  }
  long long ans = 0;
  for (long long i = 0; i <= m; ++i) {
    ans += mod[i] * (mod[i] - 1) / 2;
    if (i == 0) {
      ans += mod[i];
    }
  }
  cout << ans << endl;
  return 0;
}
