#include <bits/stdc++.h>
using namespace std;
unsigned long long comb_x_and_two(int x) { return x * (x - 1) / 2; }
int main() {
  unsigned long long n, m, x, a, dp[100001];
  unsigned long long ans = 0;
  map<unsigned long long, unsigned long long> T;
  dp[0] = 0;
  T[0] = 1;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> x;
    a = x % m;
    if (dp[i] + a >= m)
      dp[i + 1] = dp[i] + a - m;
    else
      dp[i + 1] = dp[i] + a;
    if (T.find(dp[i + 1]) == T.end())
      T[dp[i + 1]] = 1;
    else
      T[dp[i + 1]]++;
  }
  map<unsigned long long, unsigned long long>::iterator it;
  for (it = T.begin(); it != T.end(); it++) {
    pair<unsigned long long, unsigned long long> item = *it;
    ans += comb_x_and_two(item.second);
  }
  cout << ans << endl;
  return 0;
}
