#include <bits/stdc++.h>
using namespace std;
template <typename X>
bool exist(vector<X> vec, X item) {
  return find(vec.begin(), vec.end(), item) != vec.end();
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long cntN[100005];
void cal(long long N) {
  long long cnt = 0;
  for (long long i = (long long)0; i < (long long)N; i++) {
    cnt += i;
    cntN[i + 1] = cnt;
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, M;
  cin >> N >> M;
  cal(M + 1);
  vector<long long> A;
  vector<long long> sumA;
  for (long long i = (long long)0; i < (long long)N; i++) {
    long long inp;
    cin >> inp;
    A.push_back(inp);
  }
  long long s = 0;
  map<long long, long long> cnt;
  sumA.push_back(0);
  cnt[0]++;
  for (long long i = (long long)0; i < (long long)N; i++) {
    s += A[i];
    sumA.push_back(s % M);
    cnt[s % M]++;
  }
  sort(sumA.begin(), sumA.end()),
      sumA.erase(unique(sumA.begin(), sumA.end()), sumA.end());
  long long ans = 0;
  for (long long i = (long long)0; i < (long long)sumA.size(); i++) {
    ans += cntN[cnt[sumA[i]]];
  }
  cout << ans << endl;
  return 0;
}
