#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
using Graph = vector<vector<int>>;
using Edge = map<pair<int, int>, int>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T *)array, (T *)(array + N), val);
}
long long gcd(long long a, long long b) {
  if (a % b == 0)
    return (b);
  else
    return (gcd(b, a % b));
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
int main() {
  cout << fixed << setprecision(15);
  long long N, M;
  cin >> N >> M;
  map<long long, long long> C;
  vector<long long> A(N);
  for (long long i = 0; i < (long long)(N); ++i) {
    cin >> A[i];
  }
  vector<long long> B(N);
  for (long long i = 0; i < (long long)(N); ++i) {
    if (i == 0) {
      B[i] = A[i];
    }
    B[i] = B[i - 1] + A[i];
    if (C.count(B[i] % M)) {
      C[B[i] % M]++;
    } else {
      C[B[i] % M] = 1;
    }
  }
  long long ans = 0;
  for (auto c : C) {
    ans += (c.second * (c.second - 1) / 2);
    if (c.first == 0) {
      ans += c.second;
    }
  }
  cout << ans << endl;
  return 0;
}
