#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N, M;
  cin >> N >> M;
  vector<long long int> A(N);
  long long int sum;
  for (long long int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<long long int> ruiseki;
  ruiseki.push_back(0);
  for (long long int i = 0; i < N; i++) {
    sum += A[i];
    ruiseki.push_back(sum);
  }
  long long int ans = 0;
  map<long long int, long long int> result;
  for (long long int i = 0; i < ruiseki.size(); i++) {
    ruiseki[i] %= M;
    result[ruiseki[i]]++;
  }
  for (auto i = result.begin(); i != result.end(); ++i) {
    long long int value = i->second;
    ans += value * (value - 1) / 2;
  }
  cout << ans << endl;
}
