#include <bits/stdc++.h>
using namespace std;
int f[100010];
int a[100010];
map<int, int> t;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    a[i] %= m;
  }
  for (int i = 1; i <= n; ++i) f[i] = (f[i - 1] + a[i]) % m;
  int ans = 0;
  for (int i = 0; i <= n; ++i) {
    ans += t[f[i]];
    ++t[f[i]];
  }
  printf("%d", ans);
  return 0;
}
