#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;
}
template <class _Ty>
class PermComb {
 protected:
  _Ty _maxNum = 0;
  _Ty _use_mod = 0;
  _Ty* _fact = 0;
  _Ty* _inv = 0;
  _Ty* _finv = 0;
  PermComb() {}

 public:
  PermComb(_Ty maxNum, _Ty use_mod = 0) {
    _maxNum = maxNum;
    _use_mod = use_mod;
    _fact = new _Ty[(unsigned int)maxNum + 1];
    _fact[0] = _fact[1] = 1;
    if (_use_mod) {
      _inv = new _Ty[(unsigned int)maxNum + 1];
      _finv = new _Ty[(unsigned int)maxNum + 1];
      _inv[0] = _inv[1] = 1;
      _finv[0] = _finv[1] = 1;
    }
    for (_Ty i = 2; i <= maxNum; i++) {
      _fact[i] = _fact[i - 1] * i;
      if (_use_mod) {
        _fact[i] %= _use_mod;
        _inv[i] = _use_mod - _inv[_use_mod % i] * (_use_mod / i) % _use_mod;
        _finv[i] = _finv[i - 1] * _inv[i] % _use_mod;
      }
    }
  }
  virtual _Ty GetPermAns(int n, int k) {
    if ((k > _maxNum) || (n > _maxNum) || (k > n) || (k < 0) || (n < 0)) {
      return 0;
    }
    return (_fact[n] / _fact[n - k]);
  }
  virtual _Ty GetCombAns(int n, int k) {
    _Ty ans = 0;
    if ((k > _maxNum) || (n > _maxNum) || (k > n) || (k < 0) || (n < 0)) {
      ans = 0;
    } else if (_use_mod == 0) {
      ans = GetPermAns(n, k);
      ans /= _fact[k];
    } else {
      ans = _fact[n] * (_finv[k] * _finv[n - k] % _use_mod) % _use_mod;
    }
    return ans;
  }
  ~PermComb() {
    delete[] _fact;
    delete[] _inv;
    delete[] _finv;
  }
};
static void ABC105D_CandyDistribution() {
  int N, M;
  get2int(N, M);
  std::map<long long, int> modPair;
  auto sSums = new long long[N + 1];
  sSums[0] = 0;
  modPair[0]++;
  for (int i = 0; i < N; i++) {
    long long snack;
    get1int<long long>(snack);
    sSums[i + 1] = snack + sSums[i];
    long long sup = sSums[i + 1] % M;
    modPair[sup]++;
  }
  long long groups = 0;
  PermComb<long long> pc(N);
  for (auto mIt = modPair.begin(); mIt != modPair.end(); mIt++) {
    groups += pc.GetCombAns(mIt->second, 2);
  }
  printf("%lld\n", groups);
  delete[] sSums;
}
