#include <bits/stdc++.h>
using namespace std;
int ctoi(char c) {
  if (c >= '0' and c <= '9') {
    return (int)(c - '0');
  }
  return -1;
}
int alphabet_pos(char c) {
  if (c >= 'a' and c <= 'z') {
    return (int)(c - 'a');
  }
  return -1;
}
int alphabet_pos_capital(char c) {
  if (c >= 'A' and c <= 'Z') {
    return (int)(c - 'A');
  }
  return -1;
}
vector<string> split(string str, char ch) {
  int first = 0;
  int last = str.find_first_of(ch);
  if (last == string::npos) {
    last = ((int)(str).size());
  }
  vector<string> result;
  while (first < ((int)(str).size())) {
    string Ssubstr(str, first, last - first);
    result.push_back(Ssubstr);
    first = last + 1;
    last = str.find_first_of(ch, first);
    if (last == string::npos) {
      last = ((int)(str).size());
    }
  }
  return result;
}
int main() {
  int N, M;
  scanf("%d%d", &(N), &(M));
  vector<int> A(N);
  unordered_map<int, int> ump;
  for (int i = 0; i < (int)(N); ++i) {
    scanf("%d", &(A[i]));
  }
  vector<int> X(N);
  ump[0] = 1;
  for (int i = 0; i < (int)(N); ++i) {
    if (i > 0) {
      X[i] = X[i - 1] + A[i];
    } else {
      X[i] = A[i];
    }
    X[i] %= M;
    ++ump[X[i]];
  }
  long long int ans = 0;
  for (auto it = ump.begin(); it != ump.end(); ++it) {
    ans += (*it).second * ((*it).second - 1) / 2;
  }
  printf("%lld\n", (ans));
}
