#include <bits/stdc++.h>
using namespace std;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;
inline bool chmin(long long &a, long long b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
inline bool chmax(long long &a, long long b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
T seinomi(T a) {
  if (a > 0) {
    return a;
  } else {
    return 0;
  }
}
template <typename T>
T ketasuu(T num) {
  return std::to_string(num).length();
}
long long llpow(long long a, long long n) {
  if (n == 0) {
    return 1;
  } else {
    long long rep = a;
    for (long long i = 1; i < n; i++) {
      rep *= a;
    }
    return rep;
  }
}
template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value) {
  while (first != last) {
    *first++ = value;
    ++value;
  }
}
template <typename T>
T amarinasi(T a, T b) {
  if (a % b == 0) {
    return a / b;
  } else if (a % b > 0) {
    return a / b + 1;
  } else {
    return a / b - 1;
  }
}
vector<vector<long long>> nCr_v(5010, vector<long long>());
bool nCr_maekeisan = false;
void nCr_Calculater() {
  for (int i = 0; i < 5010; i++) {
    nCr_v[i][0] = 1;
    nCr_v[i][i] = 1;
  }
  for (int k = 1; k < 5010; k++) {
    for (int j = 1; j < k; j++) {
      nCr_v[k][j] = (nCr_v[k - 1][j - 1] + nCr_v[k - 1][j]);
    }
  }
}
long long nCr(long long n, long long r) {
  if (n > 5010 || r > 5010) {
    cout << "ERROR! over range" << endl;
    return 0;
  }
  if (n < 0 || r < 0) {
    return 0;
  } else {
    if (nCr_maekeisan == false) {
      for (long long i = 0; i < 5010; i++) {
        nCr_v[i].resize(5010);
      }
      nCr_Calculater();
      nCr_maekeisan = true;
    }
    return nCr_v[n][r];
  }
}
int main() {
  long long n, m;
  cin >> n >> m;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  map<long long, long long> rensou;
  long long ruiseki[n + 1];
  ruiseki[0] = a[0] % m;
  rensou[ruiseki[0]]++;
  for (long long i = 0; i < n; i++) {
    ruiseki[i + 1] = ruiseki[i] + a[i];
    ruiseki[i + 1] %= m;
    rensou[ruiseki[i + 1]]++;
  }
  long long ans = 0;
  for (auto f : rensou) {
    ans += nCr(f.second, 2);
  }
  cout << ans << endl;
}
