#include int a[10000]; int abs(int x) { return x > 0 ? x : -x; } int main() { int n,b,c; while (scanf("%d%d%d",&n,&b,&c) != EOF) { int ans = 0; for (int i = 1;i <= n;i++) scanf("%d",&a[i]); for (int i = 1;i <= n;i++) for (int j = i + 1;j <= n;j++) if (abs(a[i] - a[j]) % b == c) ans++; printf("%d\n",ans); } }