#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll mod = 1000000007;
ll INF = 1000000099;
map<ll, ll> ma;
vector<int> v;
signed main() {
  int n, m, x = 0, ans = 0;
  cin >> n >> m;
  ma.emplace(0, 1);
  v.push_back(x);
  for (int i = 0; i < n; i++) {
    ll in;
    cin >> in;
    x += in;
    x %= m;
    if (!ma.count(x)) {
      ma.emplace(x, 1);
      v.push_back(x);
    } else {
      ma.at(x)++;
    }
  }
  sort(v.begin(), v.end());
  unique((v).begin(), (v).end());
  for (ll i = 0; i < (ll)(v).size(); i++) {
    ll y = ma.at(v.at(i));
    ans += y * (y - 1) / 2;
  }
  cout << ans << endl;
}
