#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  vector<ll> A(n);
  for (int i = 0; i < n; i++) cin >> A[i];
  vector<ll> B(n + 1, 0);
  map<int, int> mp;
  for (int i = 1; i <= n; i++) {
    B[i] += (B[i - 1] + A[i - 1]) % m;
    mp[B[i]]++;
  }
  ll ans = 0;
  for (auto x : mp) {
    if (x.first == 0) ans += x.second;
    ans += x.second * (x.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
