#include <bits/stdc++.h>
using namespace std;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
  fill((T*)array, (T*)(array + N), val);
}
template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmin(T& a, T b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
void vdebug(vector<T> v) {
  cout << "vdebug" << endl;
  for (auto vv : v) {
    cout << vv << " ";
  }
  cout << endl;
}
template <typename T>
void adebug(T arr[], long long n) {
  cout << "adebug" << endl;
  for (long long i = 0; i <= n; i++) {
    cout << arr[i] << " ";
  }
  cout << endl;
}
template <typename T1, typename T2>
void mdebug(map<T1, T2> mp) {
  cout << "mdebug" << endl;
  for (auto const& m : mp) {
    cout << m.first << " " << m.second << endl;
  }
}
template <typename T1, typename T2>
void mldebug(multimap<T1, T2> mp) {
  cout << "mldebug" << endl;
  for (auto const& m : mp) {
    cout << m.first << " " << m.second << endl;
  }
}
template <typename T1, typename T2>
void mdebugr(map<T1, T2, greater<T1>> mp) {
  cout << "mdebug" << endl;
  for (auto const& m : mp) {
    cout << m.first << " " << m.second << endl;
  }
}
template <typename T1, typename T2>
void mldebugr(multimap<T1, T2, greater<T1>> mp) {
  cout << "mldebug" << endl;
  for (auto const& m : mp) {
    cout << m.first << " " << m.second << endl;
  }
}
void ans(bool b) {
  if (b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
void ans2(bool b) {
  if (b)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m, a[100010], asum[100010];
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i <= n - 1; i++) {
    asum[i + 1] = asum[i] + a[i];
  }
  map<long long, long long> restmap;
  for (long long i = 0; i <= n - 1; i++) {
    long long rest = asum[i] % m;
    restmap[rest]++;
  }
  restmap[0]++;
  long long res = 0;
  for (auto const& r : restmap) {
    long long num = r.second;
    res += num * (num - 1) / 2;
  }
  cout << res << endl;
  return 0;
}
