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