#include <bits/stdc++.h>
using namespace std;
signed main() {
  priority_queue<int> mod;
  int n, m, a[100000], same;
  long long ans = 0, s[100001] = {}, temp;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  mod.push(0);
  for (int i = 1; i <= n; i++) {
    s[i] = s[i - 1] + a[i - 1];
    s[i] = s[i] % m;
    mod.push((int)s[i]);
  }
  while (!(mod.empty())) {
    temp = mod.top();
    mod.pop();
    same = 1;
    while (!(mod.empty()) && temp == mod.top()) {
      same++;
      mod.pop();
    }
    ans += same * (same - 1) / 2;
  }
  cout << ans << endl;
  return (0);
}
