#include <bits/stdc++.h>
using namespace std;
long long factorial(int N) {
  long long ans = 1;
  for (int i = 1; i <= N; i++) {
    ans *= i;
  }
  return ans;
}
long long combination(int N, int M) {
  return factorial(N) / (factorial(M) * factorial(N - M));
}
int main() {
  int N, M;
  cin >> N >> M;
  int a[N + 1];
  a[0] = 0;
  for (int i = 1; i <= N; i++) {
    int tmp;
    cin >> tmp;
    a[i] = (a[i - 1] + tmp) % M;
  }
  sort(a, a + N + 1);
  long long ans = 0;
  int i = 0;
  while (i < N + 1) {
    int tmp_count = 1;
    int tmp_val = a[i];
    while (i + 1 < N + 1 && a[i + 1] == tmp_val) {
      tmp_count++;
      i++;
    }
    if (i >= 2) ans += combination(tmp_count, 2);
    i++;
  }
  cout << ans << endl;
  return 0;
}
