#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  map<int64_t, int64_t> m;
  int64_t last = 0;
  m[0] = 1;
  for (int i = 0; i < N; i++) {
    int64_t tmp;
    cin >> tmp;
    last = (last + tmp) % M;
    if (m.count(last) == 0) {
      m[last] = 0;
    }
    m[last]++;
  }
  int ans = 0;
  for (auto i = m.begin(); i != m.end(); i++) {
    ans += (i->second * (i->second - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}
