#include <bits/stdc++.h>
using namespace std;
const int maxn = 100004;
int c[maxn];
int n, m, k, ans = 0;
int lowbit(int x) { return x & (-x); }
void add(int pos, int x) {
  while (pos <= n) c[pos] += x, pos += lowbit(pos);
}
int sum(int pos) {
  int sum = 0;
  while (pos) sum += c[pos], pos -= lowbit(pos);
  return sum;
}
int ij(int pos) { return sum(pos) - sum(pos - 1); }
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> k;
    add(i, k);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      int tp = 0;
      if (i == j || j == i - 1)
        tp = ij(i);
      else
        tp = sum(i - 1) - sum(j);
      if (tp % m == 0) ans++;
    }
  }
  cout << ans;
}
