#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int MOD;
struct mint {
  int n;
  mint(int n_ = 0) : n(n_) {}
};
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) {
  int x = a.n + b.n;
  return x - (x >= MOD) * MOD;
}
mint operator-(mint a, mint b) {
  int x = a.n - b.n;
  return x + (x < 0) * MOD;
}
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }
bool operator<(mint a, mint b) { return a.n < b.n; }
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  mint k;
  cin >> n >> MOD >> k;
  map<mint, ll> mp;
  ll ans = 0;
  for (int i = 0; i < (n); i++) {
    mint x;
    cin >> x;
    ans += mp[x * x * x * x - k * x]++;
  }
  cout << ans << endl;
}
