#include <bits/stdc++.h>
int main() {
  long long int n, m;
  std::cin >> n >> m;
  long long int a[n];
  long long int s[n + 1];
  s[0] = 0;
  std::map<int, int> map;
  map[0]++;
  for (long long int i = 0; i < n; i++) {
    std::cin >> a[i];
    s[i + 1] = (s[i] + a[i]) % m;
    map[s[i + 1]]++;
  }
  int ans = 0;
  for (std::map<int, int>::iterator it = map.begin(); it != map.end(); ++it) {
    int tmp = it->second;
    ans += tmp * (tmp - 1) / 2;
  }
  std::cout << ans << std::endl;
  return 0;
}
