#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000007;
const long long MAX = 210000;
const long long MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
  for (size_t i = 0; i <= n; i++) {
    pr[i] = i;
  }
}
int parent(int x) {
  if (x == pr[x]) return x;
  return pr[x] = parent(pr[x]);
}
bool unit(int x, int y) {
  int px = parent(x);
  int py = parent(y);
  if (px == py) return false;
  if (px < py) {
    pr[py] = px;
  } else {
    pr[px] = py;
  }
  return true;
}
vector<vector<int> > calcNext(const string& S) {
  int n = (int)S.size();
  vector<vector<int> > res(n + 1, vector<int>(26, n));
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
    res[i][S[i] - 'a'] = i;
  }
  return res;
}
void add(long long& a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
bool use[100010];
long long n, m;
long long a[100010];
long long sa[100010];
long long calc(int x, long long c) {
  if (x > n) {
    return c * (c + 1LL) / 2LL;
  }
  long long v = sa[x] - sa[x - 1];
  use[x] = true;
  if (v % m == 0) {
    return calc(x + 1, c + 1);
  }
  long long rem = v % m;
  while (true) {
    long long nex = rem + sa[x];
    if (nex > sa[n]) {
      long long res = 0;
      return c * (c + 1LL) / 2LL;
    }
    long long* p = lower_bound(sa, sa + n, nex);
    if (*p == nex) {
      long long pos = p - sa;
      return calc(pos + 1, c + 1);
    } else {
      rem += m;
    }
  }
}
void solv() {
  cin >> n >> m;
  for (size_t i = 0; i < n; i++) {
    cin >> a[i];
  }
  sa[0] = 0;
  for (size_t i = 1; i <= n; i++) sa[i] = a[i - 1] + sa[i - 1];
  long long res = 0;
  for (size_t i = 1; i <= n; i++) {
    long long bas = a[i];
    if (use[i]) {
      continue;
    }
    res += calc(i, 0);
  }
  cout << res << endl;
}
int main() {
  solv();
  return 0;
}
