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