#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  int A[100002];
  long long S[100002];
  map<int, int> amari;
  long long result = 0;
  cin >> N >> M;
  S[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    S[i] = S[i - 1] + A[i];
    int mod = S[i] % M;
    if (amari.find(mod) == amari.end())
      amari[mod] = 1;
    else
      amari[mod]++;
  }
  if (amari.find(0) != amari.end()) result = amari[0];
  for (map<int, int>::iterator i = amari.begin(); i != amari.end(); i++) {
    int v = i->second;
    result += v * (v - 1) / 2;
  }
  cout << result << endl;
  return 0;
}
