#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using ti = tuple<int, int, int>;
using tl = tuple<ll, ll, ll>;
template <typename T>
using vec = vector<T>;
template <typename T>
using mat = vector<vec<T>>;
template <typename T>
using cub = vector<mat<T>>;
template <typename T>
using val = valarray<T>;
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using rpq = priority_queue<T, vec<T>, greater<T>>;
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "P(" << p.first << ", " << p.second << ") ";
  return os;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  cout << "V{";
  for (int i = 0; i < (int)v.size(); ++i) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  cout << "}";
  return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &in : v) is >> in;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const valarray<T> &v) {
  cout << "V{";
  for (int i = 0; i < (int)v.size(); ++i) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  cout << "}";
  return os;
}
template <typename T>
istream &operator>>(istream &is, valarray<T> &v) {
  for (T &in : v) is >> in;
  return is;
}
int main(void) {
  int N, M;
  cin >> N >> M;
  vec<int> A(N);
  cin >> A;
  map<ll, int> mp;
  ++mp[0];
  ll asum = 0;
  for (int(i) = 0; (i) < (int)(N); ++(i)) {
    asum += A[i];
    ++mp[asum % M];
  }
  int ans = 0;
  for (auto &(i) : (mp)) {
    if (i.second == 1) continue;
    ans += i.second * (i.second - 1) / 2;
  }
  cout << ans;
}
