#include <bits/stdc++.h>
using ll = long long;
ll n, m;
std::vector<ll> vec;
std::map<ll, ll> ma;
ll ans = 0;
int main() {
  std::cin >> n >> m;
  vec.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    std::cin >> vec[i];
  }
  for (int i = 1; i <= n; i++) {
    vec[i] = vec[i] + vec[i - 1];
    ma[vec[i] % m]++;
  }
  for (auto e : ma) {
    ans += (e.second * (e.second - 1) / 2);
  }
  std::cout << ans << std::endl;
}
