#include <bits/stdc++.h>
#pragma GCC optimize("-Ofast")
using namespace std;
using ll = long long;
using ull = unsigned long long;
inline void nprint() {}
template <class Head, class... Tail>
inline void nprint(Head &&head, Tail &&...tail) {
  cout << head << endl;
  nprint(move(tail)...);
}
using cmp = complex<double>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
template <class T>
using V = vector<T>;
template <class T>
using VV = vector<V<T>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const double PI = acos(-1), EPS = 1e-10;
constexpr ll MOD = 1E9 + 7;
constexpr int dx[] = {1, 0, -1, 0};
constexpr int dy[] = {0, 1, 0, -1};
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) {
  return s << "(" << p.first << ", " << p.second << ")";
}
template <class T>
istream &operator>>(istream &is, vector<T> &st) {
  for (size_t i = 0; i < st.size(); ++i) is >> st[i];
  return is;
}
template <class T>
istream &operator>>(istream &is, vector<vector<T>> &st) {
  for (size_t i = 0; i < st.size(); ++i) is >> st[i];
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &st) {
  for (size_t i = 0; i < st.size(); ++i) {
    if (i == st.size() - 1)
      os << st[i];
    else
      os << st[i] << " ";
  }
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<vector<T>> &st) {
  for (size_t i = 0; i < st.size(); ++i) {
    os << st[i];
    if (i != st.size() - 1) os << endl;
  }
  return os;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n, m;
  cin >> n >> m;
  vi a(n);
  ll sum[n + 1];
  cin >> a;
  sum[0] = 0;
  for (ll i = (0); i < (ll)(n); ++i) {
    sum[i + 1] = (sum[i] + a[i]) % m;
  }
  ll ans = 0;
  int i = 0, j = 0;
  ++n;
  for (i = 0; i < n; ++i)
    for (j = i + 1; j < n; ++j)
      if (sum[j] == sum[i]) ++ans;
  cout << ans << endl;
}
