#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> mod(m);
  ll sum = 0;
  ll it = 0;
  for (int j = 0; j < (n); ++j) {
    int i;
    cin >> i;
    if (j == 0) {
      mod.at(i % m)++;
    } else {
      it -= i % m;
      if (it < 0) it += m;
      mod.at((it + i % m) % m)++;
    }
    sum += mod.at(it);
  }
  cout << sum << endl;
  return 0;
}
