#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double INF = 1e7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
void solve(long long N, long long M, vector<long long> A) {
  map<int, int> acc_mod;
  acc_mod[0] = 1;
  long long sum = 0;
  for (int i = (0); i < (N); ++i) {
    sum += A[i];
    sum %= M;
    acc_mod[sum]++;
  }
  sum = 0;
  for (auto m : acc_mod) {
    if (m.second >= 2) {
      sum += m.second * (m.second - 1) / 2;
    }
  }
  cout << sum << endl;
}
int main() {
  long long M;
  long long N;
  scanf("%lld", &N);
  vector<long long> A(N - 1 + 1);
  scanf("%lld", &M);
  for (int i = 0; i <= N - 1; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, M, A);
  return 0;
}
