#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, M;
  cin >> N >> M;
  vector<long long> nums(N);
  for (int i = 0; i < N; i++) {
    cin >> nums.at(i);
  }
  vector<long long> ruisekiMod(N + 1);
  vector<long long> ruisekiModCount(M);
  for (int i = 0; i < N; i++) {
    ruisekiMod.at(i + 1) = (ruisekiMod.at(i) + nums.at(i)) % M;
    ruisekiModCount.at(ruisekiMod.at(i + 1))++;
  }
  long long answer = 0;
  for (int i = 0; i < N; i++) {
    long long currentMod = ruisekiMod.at(i);
    answer += ruisekiModCount.at(currentMod);
    ruisekiModCount.at(ruisekiMod.at(i + 1))--;
  }
  cout << answer << endl;
  return 0;
}
