#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N);
  map<long long, long long> mp;
  mp[0]++;
  long long sum = 0;
  long long res = 0;
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
    mp[sum % M]++;
  }
  for (auto& p : mp) {
    long long n = p.second;
    res += (n * (n - 1)) / 2;
    if (n % M == 0) res++;
  }
  cout << res << endl;
  return 0;
}
