#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N + 1), SUM(N + 1);
  for (int i = 1; i < N + 1; i++) cin >> A[i];
  for (int i = 1; i < N + 1; i++) SUM[i] = SUM[i - 1] + A[i];
  map<int, int> MP;
  for (int i = 0; i < N + 1; i++) MP[SUM[i] % M]++;
  long long ans = 0;
  for (auto e : MP) {
    ans += e.second * (e.second - 1) / 2;
  }
  cout << ans << endl;
}
