#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M, ans = 0;
  cin >> N >> M;
  long long A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 1; i < N; i++) A[i] += A[i - 1];
  vector<long long> v;
  set<long long> s;
  for (int i = 0; i < N; i++) {
    v.push_back(A[i] % M);
    s.insert(A[i] % M);
  }
  v.push_back(0);
  s.insert(0);
  sort(v.begin(), v.end());
  for (auto x : s) {
    int n =
        upper_bound(v.begin(), v.end(), x) - lower_bound(v.begin(), v.end(), x);
    if (n > 1) {
      ans += n * (n - 1) / 2;
    }
  }
  cout << ans << endl;
}
