#include <bits/stdc++.h>
using namespace std;
int N, M;
long long sum = 0;
int main() {
  cin >> N >> M;
  vector<int> vec(N + 1);
  int v;
  for (int i = 1; i <= N; i++) {
    cin >> v;
    vec[i] = (vec[i - 1] + v) % M;
  }
  sort(vec.begin(), vec.end());
  int i = 1;
  int j = 0;
  while (i <= N) {
    while (vec[i] == vec[i + j]) j++;
    if (vec[i] == 0)
      sum += (j + 1) * j / 2;
    else
      sum += j * (j - 1) / 2;
    i += j;
    j = 0;
  }
  cout << sum << endl;
  return 0;
}
