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