#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t N, M;
  cin >> N >> M;
  vector<int64_t> A(N);
  for (int64_t i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int64_t Ans = 0;
  vector<int64_t> Sum(N);
  int64_t sum = 0;
  for (int64_t i = 0; i < N; i++) {
    sum += A.at(i);
    Sum.at(i) = sum;
    if (sum % M == 0) {
      Ans++;
    }
  }
  for (int64_t i = 0; i < N - 1; i++) {
    for (int64_t j = 1; j < N - i; j++) {
      Sum.at(i + j) -= A.at(i);
      if (Sum.at(i + j) % M == 0) {
        Ans++;
      }
    }
  }
  cout << Ans << endl;
}
