#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int main() {
  int N;
  long long M;
  cin >> N >> M;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  map<long long, int> m;
  vector<long long> X;
  long long s = 0;
  m[0]++;
  for (int i = 0; i < N; i++) {
    s += A[i];
    s %= M;
    m[s]++;
    X.push_back(s);
  }
  sort(X.begin(), X.end());
  long long ans = 0;
  for (int i = 0; i < X.size(); i++) {
    if (i == 0 || X[i] != X[i - 1]) {
      ans += m[X[i]] * (m[X[i]] - 1) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
