#include <bits/stdc++.h>
using ll = long long;
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INFLL = 1LL << 60;
const int INF = 1 << 30;
const double PI = acos(-1);
int main() {
  int n;
  ll m;
  int ans = 0;
  ll sum = 0LL;
  cin >> n >> m;
  vector<long long> a(n);
  map<ll, ll> dis;
  for (int i = 0, i_len = (int)(n); i < i_len; i++) {
    cin >> a[i];
    a[i] %= m;
    sum += a[i];
    sum %= m;
    dis[sum]++;
  }
  for (auto itr = (dis).begin(), itr_fin = (dis).end(); itr != itr_fin; itr++) {
    if (itr->first == 0) {
      ans += itr->second * (itr->second + 1) / 2LL;
    } else {
      ans += itr->second * (itr->second - 1) / 2LL;
    }
  }
  cout << ans << endl;
}
