#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<long long> B(A.size() + 1);
  partial_sum(A.begin(), A.end(), B.begin());
  map<int, int> ma;
  for (auto b : B) {
    ma[b % M]++;
  }
  long long sum = 0;
  for (auto m : ma) {
    sum += m.second * (m.second - 1) / 2;
  }
  cout << sum << endl;
}
