#include <bits/stdc++.h>
using namespace std;
long long unsigned int cmb(long long unsigned int n) {
  return (n * (n - 1)) / 2;
}
int main(void) {
  long long unsigned int n, m;
  unordered_map<long long unsigned int, long long unsigned int> b;
  cin >> n >> m;
  long long unsigned int md(0);
  for (int i(0); i < n; i++) {
    long long unsigned int tmp;
    cin >> tmp;
    md += tmp;
    md %= m;
    b[md]++;
  }
  long long unsigned int ans(0);
  b[0]++;
  for (auto itr = b.begin(), e = b.end(); itr != e; itr++) {
    long long unsigned int tmp = itr->second;
    cout << "first: " << itr->first << "second: " << tmp << endl;
    ans += cmb(tmp);
  }
  cout << ans << endl;
  return 0;
}
