#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, cha, ans = 0;
  vector<long long int> v;
  cin >> n >> m;
  v.resize(n + 1);
  v[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    v[i] += v[i - 1];
    v[i] = v[i] % m;
    if (v[i] == 0) ans++;
  }
  sort(v.begin() + 1, v.end());
  for (int i = 1; i < v.size(); i++) cout << v[i] << endl;
  cha = 0;
  for (int i = 2; i < v.size(); i++) {
    if (v[i] == v[i - 1])
      cha++;
    else {
      ans += cha * (cha + 1) / 2;
      cha = 0;
    }
  }
  if (cha > 1) ans += cha * (cha + 1) / 2;
  cout << ans << endl;
}
