#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  map<int, int> M;
  int n, m, k, p = 0;
  ll c = 0;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &k);
    p = (p + k) % m;
    M[p]++;
  }
  for (auto &i : M) {
    c += ((i.second) - 1) * i.second / 2;
  }
  c += M[0];
  cout << c << "\n";
  return 0;
}
