#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
bool chmax(T &a, const U &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, const U &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
  bool flag = false;
  long long ans = 0, sum = 0;
  int n, m;
  cin >> n >> m;
  vector<int> a(n), ms(n);
  map<int, long long> ma;
  cin >> a[0];
  ms[0] = a[0] % m;
  ma[ms[0]]++;
  for (int a_ = (1), b_ = (n - 1), i = a_; i < b_; ++i) {
    cin >> a[i];
    ms[i] = (ms[i - 1] + a[i]) % m;
    ma[ms[i]]++;
  }
  for (auto p : ma) {
    long long add = p.second * p.second / 2;
    ans += add;
  }
  cout << ans << endl;
  return 0;
}
