#include <bits/stdc++.h>
#pragma GCC optimize("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using Int = long long;
using uint = unsigned int;
using uInt = unsigned long long;
constexpr int mod = 998244353;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
template <class T>
inline bool cmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool cmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int n, m, _, x, y, q;
string s, sb;
bool ok;
char cf, cb;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(0);
  cin >> n >> m;
  int a[n], sum[n + 1];
  sum[0] = 0;
  unordered_map<int, Int> p;
  p[0]++;
  for (int(i) = 0; i < n; ++i) {
    cin >> x;
    a[i] = x % m;
    sum[i + 1] = (sum[i] + a[i]) % m;
    p[sum[i + 1]]++;
  }
  Int ans = 0;
  for (pair<int, int> e : p)
    if (e.second > 1) ans += e.second * (e.second - 1) / 2;
  {
    cout << ans << '\n';
    return 0;
  }
}
