#include <bits/stdc++.h>
using namespace std;
long long int mi(long long int x, long long int y) {
  if (x < y) return x;
  return y;
}
int a[100000];
int b[100000];
int compare_int(const void *a, const void *b) {
  long long int *A = (long long int *)a;
  long long int *B = (long long int *)b;
  return *A - *B;
}
int main(void) {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  long long int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    sum %= m;
    b[i] = sum;
  }
  qsort(b, n, sizeof(int), compare_int);
  int mem = 0;
  int count = 1;
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    if (mem == b[i])
      count++;
    else {
      ans += (count - 1) * count / 2;
      mem = b[i];
      count = 1;
    }
  }
  ans += (count - 1) * count / 2;
  printf("%lld\n", ans);
  return 0;
}
