#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, cnt = 0, m, x;
  long long sum = 0;
  long long s = 0;
  vector<long long> v;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  v[0] = v[0] % m;
  for (i = 1; i < n; i++) {
    v[i] += v[i - 1];
    v[i] = v[i] % m;
  }
  sort(v.begin(), v.end());
  for (i = 0; i < v.size(); i++) {
    if (v[i] == 0) cnt++;
    if (v[i] == v[i - 1])
      s++;
    else
      s = 0;
    cnt += s;
  }
  cout << cnt << "\n";
  return 0;
}
