title: Maximize the sum of difference between adjacent elements in a list [Python]
body: <p>Problem statement : There are N elements in a list ,arrange them in such a manner that maximizes the sum of absolute difference of adjacent elements multiplied by the index,</p>
  
  <p>index starts from 1.</p>
  
  <p><code>(i=2,n=(elements in list))Σ i*abs(list[i-1]-list[i-2])</code></p>
  
  <p>Example :</p>
  
  <p><strong>input list</strong> :2 5 4</p>
  
  <p><strong>output</strong> : 13</p>
  
  <p><strong>explanation</strong> :</p>
  
  <p>[2,4,5] -> 2*(2) + 3*(1) = 7</p>
  
  <p>[2,5,4] -> 2*(3) + 3*(1) = 9</p>
  
  <p>[5,4,2] -> 2*(1) + 3*(2) = 8</p>
  
  <p>[5,2,4] -> 2*(3) + 3*(2) = 12</p>
  
  <p>[4,5,2] -> 2*(1) + 3*(3) = 11</p>
  
  <p>[4,2,5] -> 2*(2) + 3*(3) = 13 </p>