#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, p = 0;
  map<int, int> q;
  cin >> n >> m;
  ++q[0];
  for (int i = 1; i <= n; ++i) {
    int w;
    cin >> w;
    p = (p + w % m) % m;
    ++q[p];
  }
  long long ans = 0;
  for (auto itr = q.begin(); itr != q.end(); ++itr) {
    ans += itr->second * (itr->second - 1) / 2;
  }
  cout << ans << endl;
}
