#include <bits/stdc++.h>
long long combination(long long n, long long r) {
  if (r > n) {
    return 0;
  }
  if (r * 2 > n) r = n - r;
  long long dividend = 1;
  long long divisor = 1;
  for (long long i = 1; i <= r; ++i) {
    dividend *= (n - i + 1);
    divisor *= i;
  }
  return dividend / divisor;
}
int main() {
  long long n = 0, m = 0, ans = 0;
  int a[100000] = {}, accu[100000] = {};
  std::map<long long, long long> amari;
  std::vector<long long> num_type;
  std::cin >> n >> m;
  accu[0] = 0;
  for (long long i = 0; i < n; i++) {
    std::cin >> a[i];
    if (i == 0) {
      accu[1] = a[i];
    } else {
      accu[i + 1] = (accu[i] + a[i]);
    }
  }
  for (long long i = 0; i < n + 1; i++) {
    amari[accu[i] % m]++;
    if (amari[accu[i] % m] == 1) {
      num_type.push_back(accu[i] % m);
    }
  }
  for (long long i = 0; i < num_type.size(); i++) {
    ans += combination(amari[num_type[i]], 2);
  }
  std::cout << ans << std::endl;
  return 0;
}
