#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  map<int, int> rems;
  rems[0] = 1;
  int tmp;
  int acc = 0;
  long long total = 0;
  for (int i = 0; i < N; ++i) {
    cin >> tmp;
    acc += tmp;
    acc %= M;
    rems[acc]++;
  }
  for (auto &r : rems) {
    int rem = r.first;
    int count = r.second;
    total += static_cast<long long>((count - 1) * count / 2);
  }
  printf("%lld\n", total);
  return 0;
}
