#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, m;
  cin >> n >> m;
  ll csum[n + 1];
  csum[0] = 0;
  for (int i = 0; i < (n); i++) {
    cin >> csum[i + 1];
    csum[i + 1] += csum[i];
  }
  map<int, int> cnt_map;
  for (int i = 0; i < (n + 1); i++) cnt_map[csum[i] % m]++;
  ll ans = 0;
  for (auto mod_cnt : cnt_map) {
    int cnt = mod_cnt.second;
    if (cnt <= 1) continue;
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
