#include <bits/stdc++.h>
using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
long long int n, m;
map<long long int, long long int> a;
long long int comb(long long int n) {
  long long int x = 1;
  while (n--) {
    x *= n;
  }
  return x / 2;
}
void solve() {
  long long int ans = 0;
  for (auto pair : a) {
    long long int x = pair.second;
    if (x < 2) {
      continue;
    }
    ans += comb(x);
  }
  cout << ans << endl;
}
signed main() {
  cin >> n >> m;
  long long int sum = 0;
  a[0] = 1;
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    sum += x;
    a[sum % m]++;
  }
  solve();
  return 0;
}
