#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<long> v(n);
  for (int i = (int)(0); i < (int)(n); i++) cin >> v[i];
  vector<long> acc(n);
  acc[0] = v[0];
  for (int i = (int)(1); i < (int)(n); i++) acc[i] = acc[i - 1] + v[i];
  vector<int> cnt(m, 0);
  for (int i = (int)(0); i < (int)(n); i++) cnt[acc[i] % m]++;
  long ans = cnt[0];
  for (int i = (int)(0); i < (int)(n); i++) {
    cnt[acc[i] % m]--;
    ans += cnt[acc[i] % m];
  }
  cout << ans << endl;
  return 0;
}
