#include <bits/stdc++.h>
using namespace std;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
  std::fill((T*)array, (T*)(array + N), val);
}
int main() {
  long long n, m;
  long long a[100010];
  long long sum[100010];
  sum[0] = 0;
  unordered_map<long long, long long> count;
  count[sum[0]]++;
  std::cin >> n >> m;
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
    a[i] %= m;
    sum[i + 1] = a[i] + sum[i];
    sum[i + 1] %= m;
    count[sum[i + 1]]++;
  }
  long long result = 0;
  for (const auto& [key, value] : count) {
    if (value > 1) {
      result += value * (value - 1) / 2;
    }
  }
  std::cout << result << std::endl;
}
