#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = (int)(0); i < (int)(n); ++i) cin >> a[i];
  vector<LL> ruiseki(n + 1, 0);
  ruiseki[0] = 0;
  for (int i = (int)(0); i < (int)(n); ++i) ruiseki[i + 1] += ruiseki[i] + a[i];
  LL ans = 0;
  map<LL, LL> mp;
  for (int i = (int)(0); i < (int)(n + 1); ++i) mp[ruiseki[i] % m]++;
  for (int i = (int)(0); i < (int)(n); ++i) {
    mp[ruiseki[i] % m]--;
    ans += mp[ruiseki[i] % m];
  }
  cout << ans << endl;
}
