IMO 1986 P3: To each vertex of a pentagon, we assign an integer $x_i$ with sum $s=\sum x_i>0$. If $x,y,z$ are numbers assigned to three successive vertices and if $y<0$, then we replace $(x,y,z)$ by $(x+y,-y,y+z)$. This step is repeated as long as there is a $y<0$. Decide if the algorithm always stops. (Most difficult problem of the IMO).
How can we use the following monovariant for solving the above question?
$g(x)$$=$$\sum_{i=1}^{5}$$\sum_{j=1}^{5}$$|x_i+x_{i+1}.........x_{j-1}|$
I tried my best, but I am not able relate the following function with the question.