#include <bits/stdc++.h>
using namespace std;
void solver(int *nums, int numsSize, int m) {
  int i, j;
  int r;
  long long int sum = 0;
  long long int ret = 0;
  long long int *dp = (long long int *)calloc(m, sizeof(long long int));
  dp[0] = 1;
  for (i = 0; i < numsSize; ++i) {
    sum += nums[i];
    r = sum % m;
    ret += dp[r];
    dp[r]++;
  }
  printf("%lld\n", ret);
}
int main() {
  int i, n, m;
  int a[100001] = {0};
  scanf("%d %d", &n, &m);
  for (i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  solver(a, n, m);
  return 0;
}
