#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  multiset<long long> S = {0};
  long long ans = 0, cumsum = 0, A;
  for (int i = 0; i < N; i++) {
    cin >> A;
    cumsum = (cumsum + A) % M;
    ans += S.count(cumsum);
    S.insert(cumsum);
  }
  cout << ans << endl;
}
