#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int N, A = 0, a;
  long long M;
  map<long long, int> m;
  map<long long, bool> ind;
  vector<int> vec;
  m[0] = 1;
  ind[0] = true;
  vec.push_back(0);
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> a;
    A = (A + a) % M;
    m[A] = m[A] + 1;
    if (!ind[A]) {
      ind[A] = true;
      vec.push_back(A);
    }
  }
  long long ans = 0;
  while (!vec.empty()) {
    ans += ((m[vec.back()] - 1) * m[vec.back()]) / 2;
    vec.pop_back();
  }
  cout << ans << endl;
  return 0;
}
