#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);

  long long result = 0;

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

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

    //cout << c[i] << " ";
  }


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