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