#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1 << 30;
const ll INFll = 1ll << 62;
const ld EPS = 1e-10;
const int MOD = int(1e9) + 7;
template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  ll n, m;
  cin >> n >> m;
  Vll S(n + 1);
  for (int i = int(0); i < int(n); i++) {
    int a;
    cin >> a;
    S[i + 1] = (S[i] + a) % m;
  };
  V cnt(m);
  ll ans = 0;
  for (int i = int(0); i < int(n + 1); i++) {
    ans += cnt[S[i]];
    ++cnt[S[i]];
  }
  cout << ans << endl;
  return 0;
}
