#include <bits/stdc++.h>
using namespace std;
typedef vector<vector<long long> > VVL;
template <class T>
T IN() {
  T d;
  cin >> d;
  return d;
}
long long gcd(long long a, long long b) { return (b > 0) ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
bool uruu(long long Y) {
  return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false);
}
string Replace(string S, string from, string to) {
  auto p = S.find(from);
  while (p != string::npos) {
    S.replace(p, from.size(), to);
    p = S.find(from, p + to.size());
  }
  return S;
}
long long Ketawa_s(string s) {
  long long a = 0;
  for (int i = (0); i < (s.length()); i++) a += s[i] - '0';
  return a;
}
const long long MAX = 510000, p = 998244353;
long long fac[MAX], finv[MAX], inv[MAX];
void COM_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = (2); i < (MAX); i++) {
    fac[i] = fac[i - 1] * i % p;
    inv[i] = p - inv[p % i] * (p / i) % p;
    finv[i] = finv[i - 1] * inv[i] % p;
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % p) % p;
}
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int dxx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dyy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ;
  bool dbgF = true;
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N + 1, 0);
  for (int i = (0); i < (N); i++) A[i] = IN<long long>();
  long long ans = 0;
  vector<long long> ruisekiwa_migikara(N + 2, 0),
      ruisekiwa_hidarikara(N + 2, 0);
  for (int i = (0); i < (N); i++) {
    ruisekiwa_migikara[i + 1] = ruisekiwa_migikara[i] + A[i];
    ruisekiwa_hidarikara[i + 1] = ruisekiwa_hidarikara[i] + A[N - i - 1];
  }
  for (int i = (1); i < (N + 1); i++) {
    for (int j = (i); j < (N + 1); j++) {
      if ((ruisekiwa_migikara[j] - ruisekiwa_migikara[i - 1]) % M == 0) ans++;
    }
  }
  cout << ans << endl;
  ;
  return 0;
}
