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