#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
const long long MOD = 1e9 + 7;
const double eps = 1e-9;
int n, m, a[N], seg[4 * N], cnt[4 * N], lazy[4 * N];
void build(int p, int s, int e) {
  if (s == e) {
    seg[p] = a[s];
    if (!seg[p]) cnt[p] = 1;
    return;
  }
  build(2 * p, s, (s + e) / 2);
  build(2 * p + 1, (s + e) / 2 + 1, e);
  seg[p] = (seg[2 * p] + seg[2 * p + 1]) % m;
  cnt[p] = (cnt[2 * p] + cnt[2 * p + 1]);
}
void fix(int p, int s, int e) {
  if (lazy[p]) {
    seg[p] += (1ll * (e - s + 1) * lazy[p]) % m;
    if (seg[p] < 0) seg[p] = (seg[p] + m) % m;
    if (s != e) lazy[2 * p] += lazy[p], lazy[2 * p + 1] += lazy[p];
    if (!seg[p]) cnt[p] = 1;
    lazy[p] = 0;
  }
}
void update(int p, int s, int e, int a, int b, int v) {
  fix(p, s, e);
  if (s >= a && e <= b) {
    lazy[p] += v;
    fix(p, s, e);
    return;
  }
  if (s > b || e < a) return;
  seg[p] = (seg[2 * p] + seg[2 * p + 1]) % m;
  cnt[p] = cnt[2 * p] + cnt[2 * p + 1];
}
int get(int p, int s, int e, int a, int b) {
  fix(p, s, e);
  if (s >= a && e <= b) return cnt[p];
  if (s > b || e < a) return 0;
  return get(2 * p, s, (s + e) / 2, a, b) +
         get(2 * p + 1, (s + e) / 2 + 1, e, a, b);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = 1; i < n; i++) a[i] = (1ll * a[i - 1] + a[i]) % m;
  build(1, 0, n - 1);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += 1ll * get(1, 0, n - 1, i, n - 1);
    update(1, 0, n - 1, i, n - 1, -a[i]);
  }
  printf("%d\n", ans);
  return 0;
}
