#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  map<int, int> rems;
  int tmp;
  long long acc = 0;
  int rem;
  for (int i = 0; i < N; ++i) {
    cin >> tmp;
    acc += tmp;
    rem = static_cast<int>(acc % M);
    if (rems.find(rem) == rems.end()) {
      rems.insert(make_pair(rem, 1));
    } else {
      rems[rem]++;
    }
  }
  int total = 0;
  for (auto &r : rems) {
    int rem = r.first;
    int count = r.second;
    if (count >= 2) total += (count - 1) * count / 2;
    if (rem == 0) total += count;
  }
  cout << total << '\n';
  return 0;
}
