#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  int N, M, A, cumsum = 0;
  cin >> N >> M;
  map<int, ll> S;
  S[0] = 1;
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> A;
    cumsum = (cumsum + A) % M;
    ans += S[cumsum];
    S[cumsum]++;
  }
  cout << ans << endl;
}
