#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
int main() {
  ll N, M, m = 0, ans = 0;
  cin >> N >> M;
  vector<ll> A(N), B(M, 0);
  B.at(0) = 1;
  for (long long i = 0; i < (N); ++i) {
    cin >> A.at(i);
    m += A.at(i);
    m %= M;
    B.at(m)++;
  }
  for (long long i = 0; i < (M); ++i) {
    ans += (B.at(i) * (B.at(i) - 1)) / 2;
  }
  cout << ans << endl;
}
