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