#include <bits/stdc++.h>
using namespace std;
bool is_prime(int k) {
  for (int j = 2; j * j <= k; j++) {
    if (k % j == 0) {
      return false;
    }
  }
  return true;
}
int main() {
  long long N, M;
  cin >> N >> M;
  long long A[N + 1];
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }
  long long kmax = 32;
  long long Aadd[N + 1];
  Aadd[0] = 0;
  for (int i = 1; i <= N; i++) {
    Aadd[i] = (Aadd[i - 1] + A[i]) % M;
  }
  sort(Aadd, Aadd + 1 + N);
  int nsame = 0;
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    if (Aadd[i] == Aadd[i - 1]) nsame++;
    if (Aadd[i] != Aadd[i - 1] || i == N) {
      if (nsame > 0) {
        if (Aadd[i - 1] == 0) {
          ans += nsame * (nsame + 1) / 2;
        } else {
          nsame++;
          ans += nsame * (nsame - 1) / 2;
        }
        nsame = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
