#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
const int M = 1e8 + 7;
int n, m, a[M], sum[N], tmp;
long long cnt = 0LL;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &tmp);
    sum[i] = (sum[i - 1] + tmp % m) % m;
    a[sum[i]]++;
  }
  for (int i = 0; i <= m - 1; i++) {
    if (i == 0) {
      cnt += a[i];
    }
    cnt += a[i] * (a[i] - 1) / 2;
  }
  printf("%lld", cnt);
  return 0;
}
