#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long INF = 10000000000000000;
double PI = 3.1415926535;
template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}
using Graph = vector<vector<long long>>;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N), sum(N + 1);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum[i + 1] = sum[i] + A[i];
    sum[i + 1] %= M;
  }
  sort(sum.begin(), sum.end());
  vector<long long> C(1, 1);
  for (int i = 0; i < N + 1; i++) {
    if (sum[i] == sum[i + 1])
      C.back()++;
    else
      C.push_back(1);
  }
  long long ans = 0;
  for (int i = 0; i < C.size(); i++) {
    ans += (C[i] * (C[i] - 1)) / 2;
  }
  cout << ans << endl;
}
