#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  int box[100005];
  for (int i = 0; i < n; i++) {
    cin >> box[i];
  }
  int sum[100005];
  map<int, int> M;
  sum[0] = 0;
  for (int i = 1; i <= n; i++) {
    sum[i] = (box[i - 1] + sum[i - 1]) % m;
    cout << sum[i] << endl;
  }
  long long int ans = 0;
  for (int i = 0; i <= n; i++) {
    ans += M[sum[i]];
    M[sum[i]]++;
  }
  cout << ans << endl;
  return 0;
}
