#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void chmin(T &a, T b) {
  if (a > b) a = b;
}
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n);
  vector<long long> v(n + 1);
  map<long long, long long> mp;
  for (int i = 0; i < (n); i++) cin >> a[i];
  v[0] = 0;
  for (int i = 1; i <= n; i++) {
    v[i] = v[i - 1] + a[i];
  }
  long long ans = 0;
  for (int i = 0; i < (n + 1); i++) {
    ans += mp[v[i] % m];
    mp[v[i] % m]++;
  }
  cout << ans << endl;
  return 0;
}
