#include <bits/stdc++.h>
using namespace std;
const int MaxN = 100000;
unsigned long long S[MaxN + 10];
void SCNF(unsigned long long &x) {
  char C;
  x = 0;
  while (true) {
    C = fgetc(stdin);
    if (C < '0' || C > '9') break;
    x = x * 10 + (C - '0');
  }
}
int main() {
  unsigned long long i;
  unsigned long long N;
  unsigned long long M;
  unsigned long long A;
  unsigned long long x;
  unsigned long long iCnt;
  unsigned long long iSum;
  scanf("%llu%llu", &N, &M);
  iSum = 0;
  iCnt = 0;
  for (i = 1; i <= N; i++) {
    SCNF(A);
    iSum += A;
    iSum %= M;
    S[i] = iSum;
  }
  sort(S, S + (N + 1));
  x = 0;
  for (i = 1; i <= N; i++) {
    if (S[i - 1] == S[i])
      x++;
    else {
      iCnt += (x + 1) * x / 2;
      x = 0;
    }
  }
  if (x > 0) iCnt += (x + 1) * x / 2;
  printf("%llu\n", iCnt);
  return 0;
}
