#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 10;
long long a[N], sum[N];
long long vis[N] = {0}, cnt = 0;
int main() {
  long long n, k;
  scanf("%lld%lld", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    sum[i] = (a[i] + sum[i - 1]) % k;
    vis[sum[i]]++;
  }
  long long ans = vis[0];
  for (int i = 0; i <= N; i++) {
    if (vis[i]) {
      ans += (vis[i] * (vis[i] - 1)) / 2;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
