#include <bits/stdc++.h>
using namespace std;
const int maxN = 100100;
const int INF = 1000000000;
long long a[maxN];
long long b[maxN];
long long c[maxN];
int n, m;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    b[i] = b[i - 1] + a[i];
    c[i] = b[i] % m;
  }
  sort(c + 1, c + 1 + n);
  c[n + 1] = INF + 20;
  int st = 1, ed = 1;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (c[i + 1] != c[i]) {
      ed = i;
      int len = ed - st + 1;
      if (c[i] == 0)
        ans += ((len + 1) * len / 2);
      else
        ans += (len - 1) * len / 2;
      st = i + 1;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
