#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  long long ans = 0;
  cin >> n >> m;
  map<int, int> c;
  long long s = 0;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    s += t;
    ++c[s % m];
  }
  for (auto i : c) {
    int t = i.second;
    ans += t * (t - 1) / 2;
  }
  ans += c[0];
  cout << ans << endl;
  return 0;
}
