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