#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
long long factorial(long long n) {
  long long result = 1;
  for (long long i = 1; i <= n; i++) {
    result *= i;
  }
  return result;
}
long long combination(long long n, long long r) {
  long long result = factorial(n) / factorial(n - r) / factorial(r);
  return result;
}
int main(void) {
  long long n, m;
  long long count;
  long long cum[100001];
  std::multimap<long long, long long> mod_map;
  cin >> n >> m;
  long long m1;
  for (int i = 0; i < n; i++) {
    cin >> m1;
    if (i == 0)
      cum[i] = m1;
    else
      cum[i] = cum[i - 1] + m1;
  }
  for (int i = 0; i < n; i++) {
    mod_map.insert(std::make_pair(cum[i] % m, cum[i]));
  }
  int prev = m;
  for (auto itr : mod_map) {
    if (prev != itr.first) {
      if (itr.first == 0) {
        if (mod_map.count(0) >= 1)
          count += combination(mod_map.count(0) + 1, 2);
      } else {
        if (mod_map.count(itr.first) >= 2) {
          count += combination(mod_map.count(itr.first), 2);
        }
      }
    }
    prev = itr.first;
  }
  cout << count << endl;
  return 0;
}
