#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  ll imos[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i > 0) {
      imos[i] = imos[i - 1] + a[i];
    } else {
      imos[i] = a[i];
    }
  }
  ll ans = 0;
  ll comb[n];
  fill(comb, comb + n, 0);
  for (int l = n - 1; l >= 0; l--) {
    for (int k = l; k < n; k++) {
      ll temp;
      if (l > 0) {
        temp = imos[k] - imos[l - 1];
      } else {
        temp = imos[k];
      }
      if (temp % m == 0) {
        comb[l]++;
        if (k < n - 1) {
          comb[l] += comb[k + 1];
        }
        break;
      }
    }
    ans += comb[l];
  }
  cout << ans << endl;
}
