#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> c(m, 0);
  int post, now;
  cin >> post;
  post %= m;
  c[post]++;
  for (int i = 1; i < n; i++) {
    cin >> now;
    post = (post + now) % m;
    c[post]++;
  }
  c[0]++;
  long long ret = 0;
  for (int i = 0; i < m; i++) {
    ret += c[i] * (c[i] - 1) / 2;
  }
  cout << ret;
  return 0;
}
