#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
  int N;
  long long M;
  cin >> N >> M;
  vector<long long> a(N);
  for (int i = 0; i < (N); i++) cin >> a[i];
  vector<long long> s(N + 1);
  for (int i = 0; i < (N); i++) s[i + 1] = s[i] + a[i];
  map<long long, long long> count;
  for (int i = 0; i < (N + 1); i++) count[s[i] % M]++;
  long long ans = 0;
  for (map<long long, long long>::iterator it = count.begin();
       it != count.end(); ++it) {
    cout << it->second << endl;
    ans += it->second * (it->second - 1) / 2;
  }
  cout << ans << endl;
}
