#include <bits/stdc++.h>
using namespace std;
int main(void) {
  cin.sync_with_stdio(false);
  long long N, M;
  cin >> N >> M;
  vector<long long> As(N);
  for (int n = 0; n < (int)(N); ++n) cin >> As[n];
  long long s = 0;
  map<long long, int> cnt;
  vector<long long> sums(N);
  for (int i = 0; i < (int)(N); ++i) {
    auto a = As[i];
    s += a;
    ++cnt[s % M];
    sums[i] = s;
  }
  long long ans = 0;
  for (auto kv : cnt) {
    auto k = kv.first;
    auto v = kv.second;
    auto tmp = v * (v - 1) / 2;
    if (k == 0) {
      tmp += v;
    }
    ans += tmp;
  }
  cout << ans << endl;
  return 0;
}
