#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  map<int, int> r;
  r[0] = 1;
  long long ans = 0;
  for (int i = 0, s = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    s = (s + a) % m;
    if (r.count(s)) ans += r[s];
    r[s]++;
  }
  printf("%lld\n", ans);
  cerr << (double) clock() / CLOCKS_PER_SEC << '\n';
  return 0;
}