#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d = 0, e[1000001], f[1000001];
inline long long read() {
  long long x, f = 1, o = 0;
  char s;
  s = getchar();
  while (s > '9' || s < '0') {
    if (s == '-') {
      f = -1;
    }
    s = getchar();
  }
  while (s <= '9' && s >= '0') {
    o = o * 10 + s - '0';
    s = getchar();
  }
  return x = o * f;
}
int main() {
  a = read();
  b = read();
  f[0] = 0;
  for (long long i = 1; i <= a; i++) {
    e[i] = read();
    f[i] = f[i - 1] + e[i];
    if (e[i] % b == 0) {
      d++;
    }
    if (f[i] % b == 0 && i != 1) {
      d++;
    }
  }
  for (long long i = 2; i < a; i++) {
    for (long long j = i + 1; j <= a; j++) {
      if ((f[j] - f[i - 1]) % b == 0) {
        d++;
      }
    }
  }
  printf("%lld\n", d);
  return 0;
}
