#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  int original_data[N + 1];
  for (int i = 1; i <= N; i++) {
    cin >> original_data[i];
  }
  long long *mod = (long long *)malloc(sizeof(long long) * M);
  memset(mod, 0, sizeof(mod));
  mod[0]++;
  long long acc[N + 1];
  memset(acc, 0, sizeof(acc));
  acc[0] = 0;
  bool *used = (bool *)malloc(sizeof(bool) * M);
  vector<int> which_to_use;
  for (int i = 1; i <= N; i++) {
    acc[i] = acc[i - 1] + original_data[i];
    int tmp = acc[i] % M;
    mod[tmp]++;
    if (!used[tmp]) {
      used[tmp] = true;
      which_to_use.push_back(tmp);
    }
  }
  long long ans = 0;
  for (int i = 0; i < which_to_use.size(); i++) {
    ans += mod[which_to_use[i]] * (mod[which_to_use[i]] - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
