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