import std.stdio,std.conv;
long[2001] a,b;
long n,x,y,ans;
void main()
{
	scanf(" %d",&n);
	for(int i=0;i<n;++i)
	{
		scanf(" %d %d",&x,&y);
		++a[to!uint(x+y)];
		++b[to!uint(1000+x-y)];
	}
	for(int i=0;i<=2000;++i)
	{
		if(a[i]>1) ans+=a[i]*(a[i]-1)/2;
		if(b[i]>1) ans+=b[i]*(b[i]-1)/2;
	}
	writeln(ans);
}
