#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007LL;
const double PI = 3.14159265358979;
void solve() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  vector<ll> sum(a);
  for (ll i = 0; i < n; ++i) cin >> a[i];
  for (ll i = 1; i < n; ++i) sum[i] += sum[i - 1];
  map<ll, ll> mp;
  for (const auto& v : sum) mp[v % m]++;
  ll ans = mp[0];
  for (const auto& m : mp) {
    ll v = m.second;
    ans += v * (v - 1) / 2;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solve();
  return 0;
}
