#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
template <class T, class U>
using P = pair<T, U>;
template <class T>
using Heap = priority_queue<T>;
template <class T>
using heaP = priority_queue<T, vector<T>, greater<T>>;
template <class T, class U>
using umap = unordered_map<T, U>;
template <class T>
using uset = unordered_set<T>;
template <class T>
bool ChangeMax(T& a, const T& b) {
  if (a >= b) return false;
  a = b;
  return true;
}
template <class T>
bool ChangeMin(T& a, const T& b) {
  if (a <= b) return false;
  a = b;
  return true;
}
template <class T, size_t N, class U>
void Fill(T (&a)[N], const U& v) {
  fill((U*)a, (U*)(a + N), v);
}
template <class T, class U>
istream& operator>>(istream& is, P<T, U>& p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& e : v) {
    is >> e;
  }
  return is;
}
int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  mp[0] = 1;
  vector<int> v(n);
  cin >> v;
  ll sum = 0;
  for (auto e : v) {
    sum += e;
    mp[sum % m]++;
  }
  ll ans = 0;
  for (auto e : mp) {
    ans += e.second * (e.second - 1) / 2;
  }
  cout << ans << endl;
}
