#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char ch = getchar();
  long long x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long s[10100101];
long long fc(long long x) {
  long long sum = 1;
  for (int i = 2; i <= x; i++) {
    sum *= i;
  }
  return sum;
}
int main() {
  long long n = read(), m = read();
  for (int i = 1; i <= n; i++) {
    long long d = read();
    s[i] = s[i - 1] + d;
    s[i] %= m;
  }
  sort(s, s + 1 + n);
  long long ss = 0, ans = 0;
  ;
  for (int i = 0; i <= n; i++) {
    ss++;
    if (s[i] != s[i + 1]) {
      ans += fc(ss) / (2ll * fc(ss - 2));
      ss = 0;
    }
  }
  cout << ans;
  return 0;
}
