#include <bits/stdc++.h>
using namespace std;
template <typename T>
T vpop(vector<T> *v) {
  T res = v->back();
  v->pop_back();
  return res;
}
char vpop(string *v) {
  char res = v->back();
  v->pop_back();
  return res;
}
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1},
          dy8[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dx4[4] = {0, 1, 0, -1},
          dy4[4] = {1, 0, -1, 0};
template <class T>
inline bool maxi(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool mini(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  long long n, m, ans = 0;
  cin >> n >> m;
  unordered_map<long long, long long> ma;
  long long in, s = 0;
  for (int i = (0), i_len = (n); i < i_len; ++i) {
    cin >> in;
    s = (s + in) % m;
    ++ma[s];
  }
  for (auto i : ma) {
    ans += i.second * (i.second - 1) / 2;
  }
  cout << (ans) << "\n";
}
