#include <bits/stdc++.h>
using namespace std;
using vi = vector<long long>;
using pint = pair<long long, long long>;
inline void io() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed << setprecision(20);
}
template <typename T>
inline void in(T &e) {
  cin >> e;
}
template <typename T>
inline void out(T e) {
  cout << e << endl;
}
const long long INF = 1LL << 55;
const long long MOD = 1000000007;
const double EPS = 1e-8;
long long n, m;
vi box;
vi ruiwa;
signed main() {
  io();
  cin >> n >> m;
  box.resize(n);
  ruiwa.resize(n + 1);
  for (long long i = 0; i < n; ++i) {
    cin >> box[i];
    ruiwa[i + 1] = box[i];
  }
  long long ans = 0;
  for (long long l = 0; l < n + 1; ++l) {
    for (long long r = l + 1; r < n + 1; ++r) {
      if ((ruiwa[r] - ruiwa[l]) % m == 0) ans++;
    }
  }
  out(ans);
  return 0;
}
