#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long m;
  cin >> m;
  int r[m];
  for (int i = 0; i < m; i++) {
    r[i] = 0;
  }
  long t = 0;
  long a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    t = (t + a) % m;
    r[t]++;
  }
  long long k = 0;
  k += ((1 + r[0]) * r[0]) / 2;
  for (int i = 1; i < m; i++) {
    if (r[i] != 0) {
      k += (r[i] * (r[i] - 1)) / 2;
    }
  }
  cout << k;
  return 0;
}
