#include <bits/stdc++.h>
using namespace std;
int main() {
  long N, M;
  cin >> N >> M;
  vector<long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<long> sumA(N + 1, 0);
  for (int i = 1; i < N + 1; i++) {
    sumA[i] = (sumA[i - 1] + A[i - 1]) % M;
  }
  sort(sumA.begin(), sumA.end());
  sumA.insert(sumA.end(), -1);
  int num = 1;
  long ans = 0;
  for (int i = 1; i < N + 2; i++) {
    if (sumA[i] != sumA[i - 1]) {
      if (num == 1) {
        continue;
      }
      ans += num * (num - 1) / 2;
      num = 1;
      continue;
    }
    num++;
  }
  cout << ans << endl;
}
