#include <bits/stdc++.h>
using namespace std;
long long comb2(int n) {
  if (n < 2)
    return 0;
  else if ((n & 1) == 0)
    return (long long)(n / 2 * (n - 1));
  else
    return (long long)((n - 1) / 2 * n);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  map<int, int> sum_modM_idx;
  int sum_modM = 0;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    sum_modM += a;
    sum_modM %= M;
    if (sum_modM_idx.count(sum_modM) <= 0) sum_modM_idx[sum_modM] = 0;
    ++sum_modM_idx[sum_modM];
  }
  long long ans = sum_modM_idx.count(0) > 0 ? sum_modM_idx[0] : 0;
  for (auto it : sum_modM_idx) {
    ans += (long long)comb2(it.second);
  }
  cout << ans << endl;
  return 0;
}
