First solution. Assume that there exists 1≤i0<n such that ai0=ai0+1. The sum of the two terms in the left hand side ai0−1ai0(ai0−1−ai0)+ai0ai0+1(ai0−ai0+1) is equal to ai0−1ai0+1(ai0−1−ai0−1). This means that we can skip i0 in the left hand side. This means that it is enough to prove this inequality when a1>a2>⋯>an>0. In this case we have
a1a2(a1−a2)+a2a3(a2−a3)+⋯+an−1an(an−1−an)=a11−a21(a1−a2)2+a21−a31(a2−a3)2+⋯+an−11−an1(an−1−an)2≥(a11−a21)+(a21−a31)+⋯+(an−11−an1)((a1−a2)+(a2−a3)+⋯+(an−1−an))2=a1an(a1−an),
by Cauchy-Schwarz inequality.
The equality holds here when
a11−a21a1−a2=a21−a31a2−a3=⋯=an−11−an1an−1−an,
which is equivalent to
a1a2=a2a3=⋯=an−1an.
This implies that n=2, otherwise a1=a3 which is rejected. Therefore, in the general case, the equality holds when at least n−2 of the n−1 inequalities a1≥a2≥⋯≥an are in fact equalities.
Second solution. We prove this inequality by induction on n≥2. For n=2, clearly both sides are the same. Assume this inequality true for n. Let a1≥a2≥…≥an≥an+1>0. We have
a1a2(a1−a2)+⋯+an−1an(an−1−an)+anan+1(an−an+1)≥a1an(a1−an)+anan+1(an−an+1)≥a1an+1(a1−an+1),
since
a1an(a1−an)=+anan+1(an−an+1)−a1an+1(a1−an+1)(a1−an)(an−an+1)(a1−an+1)≥0
The equality holds here when a1=an or when an=an+1 and there is equality in the hypothesis of induction. Therefore, in the general case, the equality holds when at least n−2 of the n−1 inequalities a1≥a2≥⋯≥an are in fact equalities.