#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  vector<ll> nums(n + 10);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ll ans = 0;
  for (int r = 0; r < n; r++) {
    int cnt = 0;
    for (int l = r; l >= 0; l--) {
      cnt += a[l];
      if (cnt != 0 && cnt % m == 0) {
        nums[r + 1] = nums[l] + 1;
        ans += nums[r + 1];
        break;
      }
    }
  }
  cout << ans << endl;
}
