#include <bits/stdc++.h>
template <class _T>
static _T tp_abs(const _T& a) {
  return ((a < 0) ? (a * -1) : a);
}
template <class _T>
static _T tp_min(_T a, _T b) {
  return a < b ? a : b;
}
template <class _T>
static _T tp_max(_T a, _T b) {
  return a > b ? a : b;
}
template <class _T>
static void get1int(_T& a) {
  const char* fmt = " %d";
  if (sizeof(_T) == sizeof(long long)) {
    fmt = " %lld";
  }
  if (scanf(fmt, &a) < 0) {
    printf("g1int Error\n");
  }
}
template <class _T>
static void get2int(_T& a, _T& b) {
  const char* fmt = " %d %d";
  if (sizeof(_T) == sizeof(long long)) {
    fmt = " %lld %lld";
  }
  if (scanf(fmt, &a, &b) < 0) {
    printf("g2int Error\n");
  }
}
template <class _T>
static void get3int(_T& a, _T& b, _T& c) {
  const char* fmt = " %d %d %d";
  if (sizeof(_T) == sizeof(long long)) {
    fmt = " %lld %lld %lld";
  }
  if (scanf(fmt, &a, &b, &c) < 0) {
    printf("g3int Error\n");
  }
}
template <class _T>
static void tp_swap(_T& right, _T& left) {
  _T tmp = right;
  right = left;
  left = tmp;
}
static void getstring(char* buff) {
  if (scanf(" %s", buff) < 0) {
    printf("getstr error!\n");
  }
}
static void ABC105D_CandyDistribution();
int main() {
  ABC105D_CandyDistribution();
  fflush(stdout);
  return 0;
}
static void ABC105D_CandyDistribution() {
  int N, M;
  get2int(N, M);
  std::map<long long, int> modPair;
  modPair[0]++;
  long long sum = 0;
  int ptnMax = 0;
  for (int i = 0; i < N; i++) {
    long long snack;
    get1int<long long>(snack);
    sum = snack + sum;
    long long sup = sum % (long long)M;
    modPair[sup]++;
    ptnMax = tp_max(modPair[sup], ptnMax);
  }
  long long groups = 0;
  for (auto mIt = modPair.begin(); mIt != modPair.end(); mIt++) {
    groups += (mIt->second) * (mIt->second - 1) / 2;
  }
  printf("%lld\n", groups);
}
