#include <bits/stdc++.h>
using namespace std;
int main() {
  long long unsigned int N, M;
  cin >> N >> M;
  vector<long long unsigned int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  vector<long long unsigned int> left_v(N + 1);
  map<long long unsigned int, int> m{};
  left_v[0] = 0;
  for (int i = 0; i < N; i++) {
    left_v[i + 1] = (left_v[i] + A[i]) % M;
  }
  for (long long unsigned int x : left_v) {
    m[x]++;
  }
  long long unsigned int count = 0;
  for (auto iter = m.begin(); iter != m.end(); iter++) {
    if (iter->second != 1) {
      count += iter->second * (iter->second - 1) / 2;
    }
  }
  cout << count << endl;
  return 0;
}
