#include <bits/stdc++.h>
using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
template <typename T, typename S>
void amax(T &x, S y) {
  if (x < y) x = y;
}
template <typename T, typename S>
void amin(T &x, S y) {
  if (y < x) x = y;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  i32 n, m;
  cin >> n >> m;
  vi64 a(n);
  for (int i = 0; i < int(n); i++) cin >> a[i];
  vi64 sums(n + 1, 0);
  for (int i = 0; i < int(n); i++) sums[i + 1] = (sums[i] + a[i]) % m;
  map<i32, i32> mp;
  mp[0]++;
  for (int i = 1; i <= int(n); i++) mp[sums[i]]++;
  i64 ans = 0;
  for (auto v : mp) {
    ans += v.second * (v.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
