#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> A(n);
  vector<long long> cum(n + 1, 0);
  for (int i = 0; i < n; i++) cin >> A.at(i);
  for (int i = 0; i < n; i++) cum.at(i + 1) = (cum.at(i) + A.at(i)) % m;
  map<int, int> Mer;
  for (int i = 0; i < n + 1; i++) Mer[cum.at(i)]++;
  long long ans = 0;
  for (auto i : Mer) {
    ans += i.second * (i.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
