#include <bits/stdc++.h>
using namespace std;
void YN(bool b) { cout << (b ? "YES" : "NO") << "\n"; }
void Yn(bool b) { cout << (b ? "Yes" : "No") << "\n"; }
void yn(bool b) { cout << (b ? "yes" : "no") << "\n"; }
template <class S>
S max(vector<S> &a) {
  return *max_element(all(a));
}
template <class S>
S min(vector<S> &a) {
  return *min_element(all(a));
}
template <class T>
void puta(T &&t) {
  cout << t << "\n";
}
template <class H, class... T>
void puta(H &&h, T &&...t) {
  cout << h << ' ';
  puta(t...);
}
template <typename ELEMENT_TYPE>
struct _setfillw {
  ELEMENT_TYPE c;
  std::streamsize w;
  _setfillw(ELEMENT_TYPE c, std::streamsize w) : w(w), c(c) {}
};
template <typename ELEMENT_TYPE>
inline _setfillw<ELEMENT_TYPE> setfillw(ELEMENT_TYPE c, std::streamsize w) {
  return _setfillw<ELEMENT_TYPE>(c, w);
}
template <typename ELEMENT_TYPE>
inline std::ostream &operator<<(std::ostream &os,
                                const _setfillw<ELEMENT_TYPE> &manip) {
  return os << std::setw(manip.w) << std::setfill(manip.c);
}
template <class T = long long>
struct Graph {
  int n;
  vector<vector<tuple<long long, T>>> edge;
  Graph(int N = 1) : n(N) { edge.resize(n); }
  void add(long long f, long long t, T c, bool d = false) {
    edge[f].emplace_back(t, c);
    if (!d) edge[t].emplace_back(f, c);
  }
  void view() {
    for (long long int i = (0); i < (n); i++)
      for (auto &e : edge[i]) puta(i, "=>", get<0>(e), ", cost :", get<1>(e));
  }
};
bool length_cmp(string &a, string &b) { return a.size() < b.size(); }
long long StoLL(string s) {
  long long num = 0;
  for (long long int i = (0); i < (s.size()); i++) {
    num = num * 10 + (s[i] ^ 48);
  }
  return num;
}
long long CtoLL(char c) {
  if ('a' <= c && c <= 'z') {
    return (long long)(c ^ 96);
  } else if ('A' <= c && c <= 'Z') {
    return (long long)(c ^ 64);
  }
  return 0;
}
long long MOD = 1000000007;
long long dx[4] = {1, 0, -1, 0};
long long dy[4] = {0, 1, 0, -1};
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  long long m;
  cin >> m;
  long long dp[100000000];
  dp[0] = 1;
  long long index = 0;
  long long ans = 0;
  for (long long int i = (1); i < (n + 1); i++) {
    long long t;
    cin >> t;
    index += t;
    index %= m;
    ans += dp[index]++;
  }
  puta(ans);
  return 0;
}
