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