#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> re(m, 0);
  int a = 0, b = 0;
  re[0] = 1;
  for (int i = 0; i < n; i++) {
    cin >> a;
    b += a;
    b = (b % m);
    re[b]++;
  }
  int ans = 0;
  for (auto&& w : re) ans += w * (w - 1) / 2;
  cout << ans << endl;
}
