#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M, A[100000], S[100001] = {0}, ans = 0;
  cin >> N >> M;
  for (int i = (0); i < (N); ++i) {
    cin >> A[i];
  }
  for (int i = (1); i < (N); ++i) {
    S[i] += (S[i - 1] + A[i - 1]) % M;
  }
  map<long long, long long> vec;
  for (int i = (0); i < (N + 1); ++i) {
    auto itr = vec.find(S[i]);
    if (itr != vec.end()) {
      vec[S[i]]++;
    } else {
      vec[S[i]] = 1;
    }
  }
  for (auto itr = vec.begin(); itr != vec.end(); ++itr) {
    ans += itr->second * (itr->second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
