#include <bits/stdc++.h>
int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> a(n, 0);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
  }
  std::vector<std::vector<int>> memory(n, std::vector<int>(m, 0));
  for (int mi = 0; mi < m; mi++) {
    memory[n - 1][mi] = (a[n - 1] % m == mi ? 1 : 0);
  }
  for (int ni = n - 2; ni >= 0; ni--) {
    for (int mi = 0; mi < m; mi++) {
      int rem = a[ni] % m;
      memory[ni][mi] =
          (a[ni] % m == mi ? 1 : 0) + memory[ni + 1][(m - rem + mi) % m];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += memory[i][0];
  }
  std::cout << ans << std::endl;
  return 0;
}
