#include <bits/stdc++.h>
using namespace std;
int N;
long long int M;
long long int B[100005];
int main() {
  scanf("%d%lld", &N, &M);
  long long int a;
  long long int ans = 0;
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a);
    B[i] = (i == 0 ? a : (B[i - 1] + a)) % M;
    if (B[i] == 0) ans++;
  }
  if (N == 1) {
    printf("%d\n", ans);
    return 0;
  }
  sort(B, B + N);
  long long int c = 1;
  for (int i = 1; i < N; i++) {
    if (B[i] == B[i - 1])
      c++;
    else {
      ans += c * (c - 1) / 2;
      c = 1;
    }
  }
  ans += c * (c - 1) / 2;
  printf("%d\n", ans);
  return 0;
}
