#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  long N, M, buf;
  unsigned long long res = 0;
  map<int, int> m;
  cin >> N >> M;
  long A[N];
  long long sum = 0;
  m.insert(make_pair(0, 1));
  for (int i = 0; i < N; ++i) {
    cin >> buf;
    A[i] = buf % M;
    sum = (sum + buf) % M;
    if (m.find(sum) == m.end()) {
      m.insert(make_pair(sum, 1));
    } else {
      m[sum]++;
    }
  }
  for (auto itr = m.begin(); itr != m.end(); itr++) {
    int c;
    c = (*itr).second;
    res += c * (c - 1) / 2;
  }
  (cout << res << endl);
  return 0;
}
