#include <iostream>
#include <vector>
#include <map>

using namespace std;
#define int long long

int main(void){
  int ans = 0;
  int n, m;
  cin >> n >> m;
  vector<int> A(n);
  for(int i = 0; i < n; i++){
    cin >> A[i];
  }
  vector<int> B(n+1);
  B[0]=0;
  map<int, int> C;
  C[0]=1;
  for(int i = 0; i < n; i++){
    B[i+1]=(B[i]+A[i])%M;
    C[B[i+1]]++;
  }
  
  for(auto m: C){
    ans += (m.second -1) * m.second / 2;
  }
  cout << m << endl;
}