#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template <typename T = lint>
inline T in() {
  T x;
  cin >> x;
  return x;
}
signed main() {
  int n = in(), m = in();
  vector<int> sum_mod(n + 1);
  sum_mod[1] = in() % m;
  for (int i = 2; i <= n; i++) {
    scanf("%d", &sum_mod[i]);
    sum_mod[i] += sum_mod[i - 1];
    sum_mod[i] %= m;
  }
  map<int, int> mod_num;
  for (auto i : sum_mod) ++mod_num[i];
  int ans = 0;
  for (auto i : mod_num) ans += i.second * (i.second - 1) / 2;
  cout << ans << endl;
}
