#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  vector<int> sum(n + 1);
  map<int, int> mp;
  sum[0] = 0;
  for (int i = 0; i < (n); ++i) {
    sum[i + 1] = (sum[i] + a[i]) % m;
  }
  for (int i = 0; i < (n + 1); ++i) mp[sum[i]]++;
  ll ans = 0;
  for (auto x : mp) {
    int y = x.second;
    ans += y * (y - 1) / 2;
  }
  cout << ans << endl;
}
