#include<iostream>
#include<map>
using namespace std;
int main(){
  long n,m;
  cin >> n >> m;
  map<long,long> rests;
  long s = 0;
  for(int i=0;i<n;i++){
    long a;
    cin >> a;
    s = (s + a) % m;
    rests[s]++;
  }
  long ans = 0;
  for(auto r : rests) {
    if(r.first == 0) ans += r.second * (r.second + 1) /2;
    else ans += r.second * (r.second - 1) / 2;
  }
  cout << ans << endl;
}
