#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vpii = vector<pii>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;
ll mod = 0;
int main() {
  ll n;
  cin >> n >> mod;
  vector<ll> v(0);
  for (int(i)(0); (i) < (n); ++(i)) {
    ll a;
    cin >> a;
    a %= mod;
    v.push_back(a);
  }
  ll sum(0);
  vector<pllll> vs(0);
  for (int(i)(0); (i) < (n); ++(i)) {
    bool flag(false);
    ll a = v[i];
    for (unsigned(j)(0); (j) < (vs.size()); ++(j)) {
      vs[j].first += a;
      vs[j].first %= mod;
      if (vs[j].first == a) {
        ++vs[j].second;
        flag = true;
      }
      if (vs[j].first == 0) {
        sum += vs[j].second;
      }
    }
    if (!flag) {
      vs.push_back(pllll(a, 1));
      if (a == 0) {
        ++sum;
      }
    }
  }
  cout << sum << endl;
}
