#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp> >;
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ll MOD = (ll)(1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;
vector<pii> around = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1),
                      make_pair(0, -1)};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  ll a[n];
  for (ll i = 0; i < (ll)(n); ++i) cin >> a[i];
  map<ll, ll> csum, csum_cnt;
  for (ll i = 0; i < (ll)(n); ++i) csum[i] = (csum[i - 1] + a[i]) % m;
  for (ll i = 0; i < (ll)(n); ++i) csum_cnt[csum[i]]++;
  ll ans = 0;
  for (ll i = 0; i < (ll)(m); ++i) ans += csum_cnt[i] * (csum_cnt[i] - 1) / 2;
  ans += csum_cnt[0];
  cout << ans << endl;
  return 0;
}
