#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ruiseki = 0;
  multiset<int> s;
  s.insert(0);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ruiseki = (ruiseki + a[i]) % m;
    ans += s.count(ruiseki);
    s.insert(ruiseki);
  }
  cout << ans << endl;
  return 0;
}
