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