#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (int i = (0); i < (v.size()); i++) os << v[i] << " ";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
  for (typename set<T>::iterator it = v.begin(); it != v.end(); it++)
    os << *it << " ";
  return os;
}
const int maxn = 1e5 + 5;
int A[maxn];
long long sum[maxn];
long long N, M;
map<int, int> mp;
int main() {
  scanf("%lld %lld", &N, &M);
  for (int i = (1); i <= (N); i++) {
    scanf("%d", &A[i]);
    A[i] %= M;
    sum[i] = (sum[i - 1] + A[i]) % M;
    cout << sum[i] << endl;
    mp[sum[i]]++;
  }
  int L = 0;
  long long n = M;
  long long ans = 0;
  while (L <= N) {
    ans += mp[M - n];
    mp[sum[L + 1]]--;
    n = (M - sum[L + 1]) % M;
    if (n == 0) n = M;
    L++;
  }
  cout << ans << endl;
  return 0;
}
