#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 + 1;
const ll LINF = (ll)1e18 + 1;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  std::cin >> N >> M;
  vector<ll> a_sum(1, 0);
  a_sum.reserve(N + 1);
  for (decltype(N) i = 0; i < N; i++) {
    ll a;
    std::cin >> a;
    a_sum.push_back(a + a_sum[i]);
  }
  map<int, int> map;
  for (const auto& v : a_sum) {
    auto itr = map.find(v % M);
    if (itr != map.end()) {
      itr->second++;
    } else {
      map.emplace(v % M, 1);
    }
  }
  ll ans = 0;
  for (const auto& v : map) {
    ans += (v.second * (v.second + 1)) / 2 - v.second;
  }
  std::cout << ans << std::endl;
  return 0;
}
