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