#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int n, k, p;
int a[maxn];
unordered_map<int, int> mp;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> p >> k;
  for (int i = 0; i < n; ++i) {
    long long t;
    cin >> t;
    a[i] = t * t % p * t % p * t % p;
    a[i] = ((a[i] - k * t) % p + p) % p;
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    int t = mp[a[i]];
    ans += t;
    mp[a[i]] = t + 1;
  }
  cout << ans << endl;
  return 0;
}
