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