output_description: Print the longest possible total distance Takahashi walks during the process.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      L N
      X_1
      :
      X_N
attempt: l = int(input())
  n = int(input())
  x = [int(i) for i in input().split()]
  
  k = 0
  sum = 0
  while i > 1
      if 10 + k - x[n-i] < x[i] - k:
          k = x[i]
          sum = sum + x[i] - k
          del x[i]
          n = n - 1
      else:
          k = x[n-i]
          sum = sum + 10 + k - x[n-i]
          del x[n-i]
          n = n - 1
  
  print(sum)
  
problem_description: Statement
  
  Takahashi Lake has a perimeter of L. On the circumference of the lake, there
  is a residence of the lake's owner, Takahashi. Each point on the circumference
  of the lake has a coordinate between 0 and L (including 0 but not L), which is
  the distance from the Takahashi's residence, measured counter-clockwise.
  
  There are N trees around the lake; the coordinate of the i-th tree is X_i.
  There is no tree at coordinate 0, the location of Takahashi's residence.
  
  Starting at his residence, Takahashi will repeat the following action:
  
    * If all trees are burnt, terminate the process.
    * Specify a direction: clockwise or counter-clockwise.
    * Walk around the lake in the specified direction, until the coordinate of a tree that is not yet burnt is reached for the first time.
    * When the coordinate with the tree is reached, burn that tree, stay at the position and go back to the first step.
  
  Find the longest possible total distance Takahashi walks during the process.
samples: [{"input": "10 3\n    2\n    7\n    9", "output": "15\n    \n\nTakahashi walks the distance of 15 if the process goes as follows:\n\n  * Walk a distance of 2 counter-clockwise, burn the tree at the coordinate 2 and stay there.\n  * Walk a distance of 5 counter-clockwise, burn the tree at the coordinate 7 and stay there.\n  * Walk a distance of 8 clockwise, burn the tree at the coordinate 9 and stay there.\n\n* * *"}, {"input": "10 6\n    1\n    2\n    3\n    6\n    7\n    9", "output": "27\n    \n\n* * *"}, {"input": "314159265 7\n    21662711\n    77271666\n    89022761\n    156626166\n    160332356\n    166902656\n    298992265", "output": "1204124749"}]