#include <bits/stdc++.h>
using namespace std;
map<int, long long> mmp;
int qq[100000 + 100];
int pp[100000 + 100];
int len = 0;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  long long sum = 0;
  long long uu = 0;
  mmp[0] = ++len;
  qq[len] = 0;
  pp[len]++;
  for (int i = 0; i < n; i++) {
    int num;
    scanf("%d", &num);
    uu += num;
    int p = uu % m;
    if (mmp[p] == 0) {
      mmp[p] = ++len;
      qq[len] = p;
      pp[len]++;
    } else
      pp[mmp[p]]++;
  }
  for (int i = 1; i <= len; i++) sum += (pp[i] - 1) * pp[i] / 2;
  printf("%lld\n", sum);
  return 0;
}
