#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
const long long mod = 1e9 + 7;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  long long m;
  cin >> n >> m;
  vector<long long> A(n), sum(n + 1);
  for (int i = (int)(0); i < (int)(n); i++) {
    cin >> A[i];
    sum[i + 1] = sum[i] + A[i];
  }
  map<long long, int> rem;
  for (int i = (int)(0); i < (int)(n + 1); i++) rem[sum[i] % m]++;
  long long ans = 0;
  for (auto ele : rem) {
    ans += ele.second * (ele.second - 1) / 2;
  }
  cout << ans << "\n";
  return 0;
}
