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