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