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

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