#include <bits/stdc++.h>
int main(void) {
  long long counter = 0;
  int i, j, N, M, val;
  scanf("%d %d", &N, &M);
  int a[N + 1];
  a[0] = 0;
  for (i = 1; i <= N; i++) {
    scanf("%d", &val);
    a[i] = (a[i - 1] + val) % M;
  };
  for (i = 1; i <= N; i++) {
    if (a[i] == 0) {
      counter++;
    }
    for (j = i + 1; j <= N; j++) {
      if (a[i] == a[j]) {
        counter++;
      }
    }
  }
  printf("%lld\n", counter);
  return 0;
}
