#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  unordered_map<ll, ll> mp;
  mp[0]++;
  ll pre = 0;
  for (int i = 0; i < n; ++i) {
    ll a;
    cin >> a;
    pre += a;
    mp[pre % m]++;
  }
  ll ans = 0;
  for (auto p : mp) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;
}