#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
void coY() { cout << "Yes" << endl; }
void coN() { cout << "No" << endl; }
const ll INF = 1LL << 60;
const int mod = 1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = (0); i < (n); ++i) cin >> a[i];
  map<int, int> P;
  int wa = 0;
  P[wa]++;
  for (int i = (0); i < (n); ++i) {
    wa += a[i];
    wa %= m;
    P[wa]++;
  }
  ll ans = 0;
  for (auto x : P) {
    int N = x.second;
    ans += (ll)(N * (N - 1)) / 2;
  }
  cout << ans << endl;
}
