Let p be an odd prime and let d be an integer not divisible by p. We prove that p∤m2−dn21≤m,n≤p−1∏(x−(m+nd))≡{∑k=1p−22k(k+1)x(k−1)(p−1)(modp)∑k=0(p−1)/2x2k(p−1)(modp)if(pd)=1,if(pd)=−1, where (pd) denotes the Legendre symbol. This extends a recent conjecture of N. Kalinin. We also obtain the Wolstenholme-type congruence p∤m2−dn21≤m,n≤p−1∑m+nd1≡0(modp2).