#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N + 1);
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
  }
  long long temp = 0;
  map<long long, long long> count;
  vector<long long> elem;
  for (long long i : A) {
    temp = (temp + i) % M;
    if (count.find(temp) != count.end()) {
      count[temp]++;
    } else {
      count[temp] = 1;
      elem.push_back(temp);
    }
  }
  long long ans = 0;
  for (long long i = 0; i < elem.size(); i++) {
    long long curr = count[elem[i]];
    ans += (long long)curr * (curr - 1) / 2;
  }
  cout << ans << endl;
}
