In space, we are given the points $A,B,C$ and a sphere with center $O$ and radius $1$. Find the point $X$ from the sphere for which the sum $f(X)=|XA|^2+|XB|^2+|XC|^2$ attains its maximal and minimal value. Prove that if the segments $OA,OB,OC$ are pairwise perpendicular and $d$ is the distance from the center $O$ to the centroid of the triangle $ABC$ then: (a) the maximum of $f(X)$ is equal to $9d^2+3+6d$; (b) the minimum of $f(X)$ is equal to $9d^2+3-6d$. K. Dochev and I. Dimovski