#include <bits/stdc++.h>
using namespace std;
int pow2(uint32_t e) {
  int p = 1;
  for (uint32_t i = 0; i < e; ++i) {
    p *= 2;
  }
  return p;
}
int nCr(int n, int r) {
  int ret = 1;
  for (int i = 0; i < r; ++i) {
    ret = ret * (n - i) / (i + 1);
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  uint32_t N, M;
  cin >> N >> M;
  vector<uint32_t> vA(N);
  for (uint32_t i = 0; i < N; ++i) {
    cin >> vA[i];
  }
  vector<uint64_t> vA_sum(N);
  vA_sum[0] = vA[0];
  for (uint32_t i = 1; i < N; ++i) {
    vA_sum[i] = vA[i] + vA_sum[i - 1];
  }
  unordered_map<int, int> hashT;
  for (uint32_t i = 0; i < N; ++i) {
    int mod = vA_sum[i] % M;
    auto itr = hashT.find(mod);
    if (itr != hashT.end()) {
      ++(itr->second);
    } else {
      hashT.insert({mod, 1});
    }
  }
  int ans = 0;
  for (auto itr = hashT.begin(); itr != hashT.end(); ++itr) {
    if (itr->first != 0 && itr->second < 2) {
      continue;
    }
    if (itr->first == 0) {
      printf("imh2\n");
      ans += nCr(itr->second, 2) + itr->second;
    } else {
      printf("imh3\n");
      ans += nCr(itr->second, 2);
    }
  }
  cout << ans << endl;
  return 0;
}
