#include <bits/stdc++.h>
int main() {
  long long n, m, ret = 0;
  std::cin >> n >> m;
  std::vector<long long> a(n + 1), b(m + 1);
  b[0]++;
  for (auto i = 1ll; i <= n; i++) {
    std::cin >> a[i];
    a[i] += a[i - 1];
    b[a[i] % m]++;
  }
  for (auto i = 0ll; i < m; i++) {
    if (b[i] > 1) ret += b[i] * (b[i] - 1) / 2;
  }
  std::cout << ret << std::endl;
  return 0;
}
