#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m, ai, a;
  cin >> n >> m;
  map<int, int> mp{};
  cin >> a;
  mp[a % m]++;
  for (int i = 1; i < n; ++i) {
    cin >> ai;
    a += ai;
    mp[a %= m]++;
  }
  int ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    ans += itr->second * (itr->second - 1) / 2;
    if (itr->first == 0) {
      ans += itr->second;
    }
  }
  cout << ans << endl;
  return 0;
}
