#include <bits/stdc++.h>
int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<int> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  std::unordered_map<int, int> remainder_counts;
  int cum_remainder = 0;
  for (int i = 0; i < N; i++) {
    cum_remainder = (cum_remainder + A[i]) % M;
    remainder_counts[cum_remainder] += 1;
  }
  remainder_counts[0] += 1;
  int combinations = 0;
  for (auto kv : remainder_counts) {
    int count = kv.second;
    combinations += count * (count - 1) / 2;
  }
  std::cout << combinations << std::endl;
}
