  We consider a class of variational problems for densities that repel each
other at distance. Typical examples are given by the Dirichlet functional and
the Rayleigh functional \[
  D(\mathbf{u}) = \sum_{i=1}^k \int_{\Omega} |\nabla u_i|^2 \quad \text{or}
\quad R(\mathbf{u}) = \sum_{i=1}^k \frac{\int_{\Omega} |\nabla
u_i|^2}{\int_{\Omega} u_i^2} \] minimized in the class of
$H^1(\Omega,\mathbb{R}^k)$ functions attaining some boundary conditions on
$\partial \Omega$, and subjected to the constraint \[
  \mathrm{dist} (\{u_i > 0\}, \{u_j > 0\}) \ge 1 \qquad \forall i \neq j. \]
For these problems, we investigate the optimal regularity of the solutions,
prove a free-boundary condition, and derive some preliminary results
characterizing the free boundary $\partial \{\sum_{i=1}^k u_i > 0\}$.
