#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  vector<long long> cum(N);
  cum[0] = A[0] % M;
  for (int i = 1; i < N; i++) cum[i] = (cum[i - 1] + A[i]) % M;
  map<long long, int> group;
  group[0]++;
  for (int i = 0; i < N; i++) {
    group[cum[i]]++;
  }
  long long ans = 0;
  for (auto x : group) {
    ans += x.second * (x.second - 1) / 2;
  }
  cout << ans << endl;
}
