#include <bits/stdc++.h>
using namespace std;
void execute() {
  int N, M;
  cin >> N >> M;
  vector<long long int> cum(N + 1, 0);
  map<long long int, int> count;
  count[0]++;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    cum[i + 1] = (cum[i] + tmp) % M;
    count[cum[i + 1]]++;
  }
  long long int ans = 0;
  for (auto out : count) {
    ans += out.second * (out.second - 1) / 2;
  }
  cout << ans << endl;
  return;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  execute();
  int stop;
  cin >> stop;
  return 0;
}
