#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll _pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x;
    x = x * x;
    n >>= 1;
  }
  return res;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  ll ans = 0;
  vector<bool> memo(n, false);
  for (int i = 0; i < n; ++i) {
    if (memo[i]) continue;
    ll p = 0, q = 0;
    for (int j = i; j < n; ++j) {
      if (p == 0) memo[j] = true;
      p += a[j];
      if (p % m == 0) {
        p = 0;
        q++;
      }
    }
    ans += ((1 + q) * q) / 2;
  }
  cout << ans << endl;
}
