#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
signed main() {
  int N;
  long long M, B[100005] = {0};
  map<long long, int> make_pair;
  cin >> N >> M;
  make_pair[0]++;
  for (int i = 1; i < (N + 1); i++) {
    long long tmp;
    cin >> tmp;
    B[i] = B[i - 1] + tmp;
    make_pair[B[i] % M]++;
  }
  long long ans = 0;
  for (auto itr = make_pair.begin(); itr != make_pair.end(); itr++) {
    if (itr->second > 0) ans += (itr->second) * (itr->second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
