#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> b(n + 1);
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    b[i] = (b[i - 1] + a) % m;
  }
  sort(b.begin(), b.end());
  map<int, int> mp;
  for (int i = 0; i <= n; i++) {
    mp[b[i]]++;
  }
  ll r = 0;
  for (const auto& p : mp) {
    ll t = p.second;
    r += t * (t - 1) / 2;
  }
  cout << r << endl;
  return 0;
}
