#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chmin(T &a, T b) {
  if (a > b) a = b;
}
template <typename T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}
namespace {
template <class K, class V>
using map = unordered_map<K, V>;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}
long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
int main() {
  int N;
  long long M;
  cin >> N >> M;
  vector<long long> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  map<int, long long> dp;
  vector<long long> mod(N + 1);
  for (int i = 1; i <= N; ++i) {
    mod[i] = (mod[i - 1] + A[i - 1]) % M;
  }
  for (int i = 0; i < N; ++i) dp[i + N * i] = long long(A[i] % M == 0);
  for (int length = 2; length <= N; ++length) {
    for (int l = 0; l <= N - length; ++l) {
      int r = l + length - 1;
      dp[l + N * r] =
          dp[l + N * (r - 1)] + dp[l + 1 + N * r] - dp[(l + 1) + (r - 1) * N];
      dp[l + N * r] += long long((mod[r + 1] - mod[l] + M) % M == 0);
    }
  }
  cout << dp[0 + N * (N - 1)] << endl;
  return 0;
}
