#include <bits/stdc++.h>
using namespace std;
void CandyDistribution() {
  int N, M;
  cin >> N >> M;
  long long a[100005];
  long long res = 0;
  map<long long, long long> m;
  m[0] = 0;
  for (size_t i = 0; i < N; i++) {
    cin >> a[i];
    a[i] += (i == 0) ? 0 : a[i - 1];
    a[i] %= M;
    cout << a[i] << "\n";
    if (m.count(a[i])) {
      m[a[i]]++;
      res += m[a[i]];
    } else {
      m[a[i]] = 0;
    }
  }
  cout << res;
}
int main() {
  CandyDistribution();
  return 0;
}
