#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, A[112345];
  scanf("%d%d", &N, &M);
  for (long long i = 0; i < (N); ++i) scanf("%d", &A[i]);
  map<int, int> mod;
  long long sum = 0;
  for (long long i = 0; i < (N); ++i) {
    sum += A[i];
    mod[sum % M]++;
  }
  long long count = 0;
  for (auto m : mod) {
    if (!m.first) count += m.second;
    count += m.second * (m.second - 1) / 2;
  }
  printf("%lld", count);
  return 0;
}
