An inequality about the sum of distances between points : same color $\le$ different colors?

Given $2n$ points ($B=(b_1,\dots, b_n)$ and $R=(r_1,\dots,r_n)$) by $f$ we denote the difference between the right-hand and the left-hand sides of the required inequality (1). We’ll prove that $f$ is always non-negative.

We start from one-dimensional case (which is also a still unanswered MSE question). Without loss of generality we may assume that all points belong to the segment $[-1,1]$ and some two of the points are endpoints of the segment. Then $f$ is a continuous function on a compact set, so the family of the admissible sets $B$ and $R$ on which the minimum is attained is non-empty. Take such sets $B$ and $R$ with the smallest number of different coordinates of points. We claim that this number is two. Indeed, assume that there is a group of points which are placed in one point strictly between the endpoints of the segment. When we synchronically move the group in its small convex neighborhood containing no other points of the sets $R$ and $D$, the value of $f$ changes linearly. Thus we can move the group to a side of a non-increasity of $f$ until it reach an other group of points and then merge the groups, which contradicts the minimality of the group number of the chosen sets $B$ and $R$. So we can assume that $r$ red points and $b$ points are placed at $-1$ and $n-r$ red points and $n-b$ points are placed at $1$. Then $$f=2r(n-b)+2b(n-r)-2r(n-r)+2b(n-b)=2(r-b)^2\ge 0.$$

Now we consider two-dimensional case. Let $\ell$ be a straight line making an angle $\alpha$ with $Ox$ axis. Orthogonally projecting the configuration of the points and segments between each two of them, and applying to the projected configuration one-dimensional case of the inequality, we obtain an inequality of the form

$$\sum_{x,y\in B\cup R} \varepsilon(x,y) d(x,y)|\cos(\varphi (x,y)-\alpha)|\ge 0,$$

where $\varepsilon(x,y)$ equals $1$ provided the points $x$ and $y$ have different colors and equals $-1$ otherwise, and $\varphi(x,y)$ is an angle between the $Ox$ axis and the segment $[x,y]$ (if $x=y$ then we put $\varphi(x,y)=0$). When we integrate this inequality over $\alpha\in [0,2\pi]$, all integrals $\int_{0}^{2\pi} |\cos (\varphi(x,y)-\alpha)|d\alpha$ yield the same non-zero constant so we obtain the required inequality (1).

The inequality for general $d$-dimensional case should be proved similarly, with the $(d-1)$-dimensinal sphere of line $\ell$ directions instead of one-dimensional circle of the angles $\alpha$.