#include <bits/stdc++.h>
using namespace std;
const char en = '\n';
constexpr long long INF = 1000000000;
constexpr long long MOD = 1000000007;
template <class T>
inline bool chmax(T& a, T b) {
  if (a <= b) {
    a = b;
    return true;
  } else
    return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n);
  for (int i = 0; i < (n); ++i) {
    cin >> a[i];
    a[i] %= m;
  }
  vector<long long> sum(n + 1);
  sum[0] = 0;
  for (int i = 0; i < (n); ++i) {
    sum[i + 1] = (sum[i] + a[i]) % m;
  }
  map<long long, int> mp;
  for (int i = 0; i < (n + 1); ++i) mp[sum[i]]++;
  long long ans = 0;
  for (auto& v : mp) {
    ans += v.second % 2 == 0 ? v.second / 2 * (v.second - 1)
                             : (v.second - 1) / 2 * v.second;
  }
  cout << ans << endl;
}
