#include <bits/stdc++.h>   using namespace std;   long long mod(long long v, long long k, long long p) {     long long res = 1;     for (long long i = 0; i < 4; i++) res *= v, res %= p;     res -= ((k * v) % p);     if (res < 0) res += p;     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n, p, k;     cin >> n >> p >> k;     long long Array[n];     for (long long i = 0; i < n; i++) cin >> Array[i];     long long B[n];     for (long long i = 0; i < n; i++) B[i] = mod(Array[i], k, p);     vector<long long> out;     sort(B, B + n);     long long cnt = 1;     for (long long i = 0; i < n - 1; i++) {       if (B[i + 1] != B[i] and cnt != 1)         out.push_back(cnt), cnt = 1;       else if (B[i + 1] == B[i])         cnt++;     }     if (cnt != 1) out.push_back(cnt);     long long sum = 0;     for (long long i = 0; i < out.size(); i++)       sum += ((out[i] * (out[i] - 1)) / 2);     cout << sum <<   n ;     return 0;   }   