prove that $g$ is a function of $(x_1-x_2,x_2-x_3,\dots,x_{n-1}-x_n)$

$g$ is a function of $(x_1-x_2,x_2-x_3,\dots,x_{n-1}-x_n)$ iff $$g(x_1+a,x_2+a,\dots,x_n+a)=g(x_1,x_2,\dots,x_n)\forall a \in \mathbb R$$

Trial: Only if part : Consider $g$ is a function of $(x_1-x_2,x_2-x_3,\dots,x_{n-1}-x_n)$ i.e. $g(x_1,x_2,\dots,x_n)=f(x_1-x_2,x_2-x_3,\dots,x_{n-1}-x_n)$.

So, we have \begin{align} g(x_1+a,x_2+a,\dots,x_n+a) &= f(x_1+a-x_2-a,x_2+a-x_3-a,\dots,x_{n-1}+a-x_n-a)\\&=f(x_1-x_2,x_2-x_3,\dots,x_{n-1}-x_n)\\&=g(x_1,x_2,\dots,x_n) \end{align}

Help me to prove the if part. Thanks in advance

Suppose $g(x_1, ..., x_n) = g(x_1 + a, ..., x_n + a)$ for all $a \in \mathbb{R}$ (1).
Then define $f(y_1, ..., y_{n-1}) := g(y_1 + ... + y_{n-1}, y_2 + ... + y_{n-1}, ..., y_{n-1}, 0)$
Then $f(x_1 - x_2, ..., x_{n-1} - x_n) = g(x_1 - x_n, x_2 - x_n, ..., x_{n-1} - x_n, x_n - x_n) = g(x_1, x_2, .., x_{n-1}, x_n)$
(the last equality taking $a = x_n$ in (1))