#include <bits/stdc++.h>
using ll = long long;
int main() {
  ll n, m, a[100001] = {0}, wa[100001] = {0};
  std::cin >> n >> m;
  ll sum = 0, ans = 0;
  std::map<int, int> p{{0, 1}};
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
    sum += a[i];
    wa[i + 1] = sum;
    p[wa[i + 1] % m]++;
  }
  for (auto it : p) {
    int pi = it.second;
    ans += pi * (pi - 1) / 2;
  }
  std::cout << ans << std::endl;
  return 0;
}
