#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long f = 1, x = 0;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * f;
}
long long a[100010], s[100010];
map<int, int> mp;
int main() {
  int n, m;
  n = read();
  m = read();
  mp[0]++;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    s[i] = s[i - 1] + a[i];
    ans += mp[s[i] % m];
    mp[s[i] % m]++;
  }
  printf("%d\n", ans);
}
