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