#include <bits/stdc++.h>
using namespace std;
long long comb(long long n, long long k) {
  long long m = 1;
  if (n < 2 * k) {
    k = n - k;
  }
  for (long long i = 1; i <= k; i++) {
    m = m * (n - i + 1) / i;
  }
  return m;
}
int main(void) {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> b(n + 1);
  b[0] = 0;
  for (int i = 1; i < n + 1; i++) {
    b[i] = b[i - 1] + a[i - 1];
  }
  int ans = 0;
  map<long long, long long> mp;
  for (int i = 0; i <= n; i++) {
    mp[b[i] % m] += 1;
  }
  for (auto i : mp) {
    if (i.second >= 2) {
      ans += comb(i.second, 2);
    }
  }
  cout << ans << endl;
}
