#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(N);
  for (size_t i = 0; i < N; i++) {
    cin >> a[i];
  }
  map<int, int> mod;
  a[0] %= M;
  mod[a[0]]++;
  for (size_t i = 1; i < N; i++) {
    a[i] = (a[i - 1] + a[i]) % M;
    mod[a[i]]++;
  }
  long long ret;
  for (auto pair : mod) {
    ret += pair.second * (pair.second - 1) / 2;
    if (pair.first == 0) ret += pair.second;
  }
  cout << ret << endl;
  return 0;
}
