#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using  namespace std;
typedef long long ll;

ll search(ll *A, bool *F, int i, int n, int m) {
  ll sum, ctr;
  sum = ctr = 0;
  for (int j = i; j < n; ++j) {
    sum += A[j];
    if (sum % m == 0) {
      F[j+1] = 1;
      ++ctr;
    }
  }
  return ctr;
}

int main()
{
  int n, m;
  cin >> n >> m;
  ll A[n];
  rep(i, n) cin >> A[i];
	
  ll B[n+1] = {};
  for (int i = n-1; i >= 0; --i) {
    B[i] = B[i+1] + A[i];
  }
  
  bool Flag[n+1] = {};
  ll count = 0;
  rep(i, n) {
    if (!Flag[i] && B[i] >= m) {
      ll tmp = search(A, Flag, i, n, m);
      count += tmp*(tmp+1)/2;
    }
  }
  cout << count << endl;
  return 0;
}