#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int p, d, ans = 0, y = 0;
  cin >> p >> d;
  vector<int> a;
  a.push_back(0);
  for (int i = 0; i < p; i++) {
    int x;
    cin >> x;
    y = x + y;
    a.push_back(y % d);
  }
  sort(a.begin(), a.end());
  int c = count(a.begin(), a.end(), 0);
  ans = ans + c * c - c;
  for (int i = 1; i < p + 1; i++) {
    if (a.at(i) != a.at(i - 1)) {
      int h = count(a.begin(), a.end(), a.at(i));
      ans = ans + h * h - h;
      i = i + h;
    }
  }
  cout << ans / 2 << endl;
}
