#include <bits/stdc++.h>
using namespace std;
int a[100010];
long long d[100010];
map<int, int> p;
int main() {
  int n, m, y;
  long long maxi = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) d[i] = d[i - 1] + a[i];
  for (int i = 1; i <= n; i++) d[i] %= m;
  for (int i = 1; i <= n; i++) p[d[i]]++;
  for (int i = 0; i <= n; i++) {
    if (p[d[i]] > 1) {
      int t = p[d[i]] + (d[i] == 0);
      p[d[i]] = -1;
      maxi += t * (t - 1) / 2;
    }
  }
  printf("\n%lld\n", maxi);
  return 0;
}
