#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;

  long long S[N] = {}; //A[i]の累積和

  cin >> S[0];
  S[0] %= M;
  for(int i=1;i<N;i++){
    int tmp;
    cin >> tmp;
    S[i] = S[i-1] + tmp;
    S[i] %= M;
  }


  sort(S, S+N);
/*
  for(int i=0;i<N;i++){
    cout << S[i] << " ";;
  }
*/
//  cout << endl;

  long long result = 0;

  long long tmp = S[0];
  int start = 0;
  for(int i=0;i<N;i++){
    if(tmp != S[i]){
      int tmpN = i - start;
      if(tmpN > 1){
        if(tmp == 0){
          result += (tmpN+1) * tmpN / 2;
        }else{
          result += tmpN * (tmpN-1) / 2;
        }
      }

//      cout << result << " ";;

      start = i;
      tmp = S[i];
    }
  }

  if(start < N-1){
    int tmpN = N - start;
    if(tmp == 0){
      result += (tmpN+1) * tmpN / 2;
    }else{
      result += tmpN * (tmpN-1) / 2;
    }

//    cout << result << " ";;
  }

  cout << result << endl;
  return 0;
}
