#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const long long llINF = 10000000000000000;
const int MOD = 1000000007;
int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance(vec.begin(), itr);
  if (index != vec.size()) {
    return 1;
  } else {
    return 0;
  }
}
int main() {
  map<int, int> sousuu;
  int Asuu[100100];
  int N, M;
  int A[100100];
  cin >> N >> M;
  Asuu[0] = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    Asuu[i + 1] = (Asuu[i] + A[i]) % M;
    sousuu[Asuu[i + 1]] = 0;
  }
  int wa = 0;
  sousuu[0] = 1;
  for (int i = 0; i < N; i++) {
    wa = (wa + A[i]) % M;
    sousuu[wa]++;
  }
  long long joukenmitasu = 0;
  vector<int> moukensansita;
  for (int i = 0; i < N; i++) {
    if (vector_finder(moukensansita, Asuu[i + 1]) == 0) {
      joukenmitasu += (sousuu[Asuu[i + 1]] * (sousuu[Asuu[i + 1]] - 1)) / 2;
      moukensansita.push_back(Asuu[i + 1]);
    }
  }
  printf("%lld\n", joukenmitasu);
}
