#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N, M, Ans = 0;
  long long a[114514] = {};
  long long A[114514] = {};
  cin >> N >> M;
  for (long long i = 0; i < (N); ++i) {
    cin >> a[i];
    a[i] %= M;
    A[i + 1] = (A[i] + a[i]) % M;
  }
  sort(A, A + N + 1);
  long long s = 1;
  for (long long i = 0; i < (N + 1); ++i) {
    if (A[i] == A[i - 1]) {
      s++;
    } else {
      Ans += s * (s - 1) / 2;
      s = 1;
    }
  }
  Ans += s * (s - 1) / 2;
  cout << Ans << endl;
  return 0;
}
