#include <bits/stdc++.h>
using namespace std;
class XY {
 public:
  long long x, y;
  XY() { x = y = 0; }
  XY(long long u, long long v) {
    x = u;
    y = v;
  }
};
template <typename T1, typename T2>
void chmin(T1 &first, T2 second) {
  if (first > second) first = second;
}
template <typename T1, typename T2>
void chmax(T1 &first, T2 second) {
  if (first < second) first = second;
}
template <typename T1, typename T2>
long long mypow(T1 first, T2 n) {
  if (n == 0) return 1;
  if (n == 1) return first;
  if (n % 2) return first * mypow(first, n - 1);
  long long tmp = mypow(first, n / 2);
  return tmp * tmp;
}
template <typename T>
int BS(vector<T> &V, int left, int right, T key) {
  int mid = (left + right) / 2;
  if (V[mid] <= key)
    left = mid;
  else
    right = mid;
  if (right - mid == 1)
    return left;
  else
    return BS(V, left, right, key);
}
long long comb(long long n, long long r) {
  long long res = 1;
  for (long long i = 0; i < r; i++) {
    res *= n - i;
    res /= i + 1;
  }
  return res;
}
template <typename T>
T euclid(T first, T second) {
  if (second == 0)
    return first;
  else
    return euclid(second, first % second);
}
vector<long long> fact((100000), 0), fact_inv((100000), 0);
long long pow_mod(long long first, long long second) {
  long long res = 1;
  while (second > 0) {
    if (second & 1) res = res * first % (1000000007);
    first = first * first % (1000000007);
    second >>= 1;
  }
  return res;
}
void prepare_comb_mod(long long n) {
  fact[0] = 1LL;
  for (long long i = 0; i < n; i++)
    fact[i + 1] = fact[i] * (i + 1) % (1000000007);
  fact_inv[n] = pow_mod(fact[n], (1000000007) - 2);
  for (long long i = n - 1; i >= 0; i--)
    fact_inv[i] = fact_inv[i + 1] * (i + 1) % (1000000007);
}
long long comb_mod(long long n, long long r) {
  return (fact[n] * fact_inv[r]) % (1000000007) * fact_inv[n - r] %
         (1000000007);
}
int UFT_par[(100000)];
int UFT_rank[(100000)];
void UFT_init(int n) {
  for (long long i = 0; i < n; i++) {
    UFT_par[i] = i;
    UFT_rank[i] = 0;
  }
}
int UFT_find(int x) {
  if (UFT_par[x] == x) {
    return x;
  } else {
    return UFT_par[x] = UFT_find(UFT_par[x]);
  }
}
void UFT_unite(int x, int y) {
  x = UFT_find(x);
  y = UFT_find(y);
  if (x == y) return;
  if (UFT_rank[x] < UFT_rank[y]) {
    UFT_par[x] = y;
  } else {
    UFT_par[y] = x;
    if (UFT_rank[x] == UFT_rank[y]) UFT_rank[x]++;
  }
}
bool UFT_same(int x, int y) { return UFT_find(x) == UFT_find(y); }
void Main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N);
  for (long long i = 0; i < N; i++) cin >> A[i];
  vector<long long> V(M);
  V[0] = 1ll;
  long long sum = 0ll;
  for (long long i = 0; i < N; i++) {
    sum += A[i];
    sum %= M;
    V[sum]++;
  }
  long long res = 0;
  for (long long i = 0; i < M; i++) {
    res += V[i] * (V[i] - 1) / 2;
  }
  cout << res << endl;
}
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);
  Main();
}
