#include <bits/stdc++.h>
using namespace std;
long long int gx = 0;
long long int n, k, m, exi, a[5000000], ama = -1, ami = 123456789102,
                                        b[5000000], ans;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] = a[i] % m;
    if (a[i] % m == 0) ans++;
    if (a[i] > ama) ama = a[i];
    if (a[i] < ami) ami = a[i];
  }
  exi = ama - ami;
  b[0] = a[0];
  for (int u = 1; u <= n; u++) {
    b[u] = a[u] + b[u - 1];
  }
  for (int i = 2; i <= n; i++) {
    gx = b[i - 1];
    for (int u = i; u <= n; u++) {
      if (gx == m) ans++;
      gx += a[u] - a[u - i];
    }
  }
  cout << ans << endl;
}
