#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  int sa[n];
  int mod_m_count[m];
  int sum = 0;
  int 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];
    sa[i] = sum;
    mod_m_count[sa[i] % m]++;
  }
  for (int i = 0; i < m; i++) ans += mod_m_count[i] * (mod_m_count[i] - 1);
  cout << ans << endl;
  return 0;
}
