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