#include <bits/stdc++.h>
using namespace std;
template <class It>
string join(It i1, It i2) {
  ostringstream ss;
  for (auto it = i1; it != i2; ++it) ss << ((it == i1) ? "" : ", ") << (*it);
  return ss.str();
}
void Print() { cout << endl; }
template <class Head, class... Args>
void Print(Head &&head, Args &&...args) {
  cout << head;
  Print(args...);
}
using ull_t = unsigned long long;
int main() {
  size_t N, M;
  cin >> N >> M;
  vector<ull_t> A(N);
  for (auto &a : A) {
    cin >> a;
    a %= M;
  }
  vector<pair<ull_t, size_t>> C;
  ull_t out = 0;
  for (auto a : A) {
    bool added = false;
    for (auto &c : C) {
      c.first += a;
      c.first %= M;
      if (c.first == a) {
        ++c.second;
        added = true;
      }
      if (c.first == 0) out += c.second;
    }
    if (not added) {
      C.push_back({a, 1});
      if (a == 0) ++out;
    }
  }
  cout << out << endl;
}
