#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
int dy[4] = {-1, 0, 0, 1};
int dx[4] = {0, 1, -1, 0};
int main() {
  ll n, m;
  cin >> n >> m;
  ll sum = 0;
  vector<ll> v(m, 0);
  v[sum]++;
  for (ll i = 0; i < (ll)n; i++) {
    ll x;
    cin >> x;
    (sum += x) %= m;
    v[sum]++;
  }
  ll res = 0;
  for (ll i = 0; i < (ll)m; i++) res += v[i] * (v[i] - 1) / 2;
  cout << res << endl;
  return 0;
}
