#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  vector<ll> cnt(m);
  int sum = 0;
  cnt[0] += 1;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    (sum += a[i]) %= m;
    cnt[sum] += 1;
  }
  ll ans = 0;
  for (auto& c : cnt) {
    ans += c * (c - 1) / 2;
  }
  cout << ans << endl;
}
