output_description: Print the maximum total happiness points the children can earn.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 A_2 ... A_N
attempt: import numpy as np
  
  N = int(input())
  
  A_list = np.array(list(map(int, input().split())))
  arg_list = np.argsort(-A_list)
  
  r_fill = 0
  l_fill = 0
  
  max_all = 0
  for i in range(N):
      max_value = 0
      max_idx = 0
      tmp_l_fill = 0
      tmp_r_fill = 0
      for idx, j in enumerate(arg_list):
          tmp_max = A_list[j] * max(j - l_fill, N - j - 1 - r_fill)
  
          if tmp_max > max_value:
              max_idx = idx
              max_value = tmp_max
              if j - l_fill > N - j - 1 - r_fill:
                  tmp_l_fill = 1
                  tmp_r_fill = 0
              else:
                  tmp_r_fill = 1
                  tmp_l_fill = 0
  
      r_fill += tmp_r_fill
      l_fill += tmp_l_fill
  
      max_all += max_value
  
      print(arg_list, max_value)
  
      arg_list = np.concatenate([arg_list[:max_idx], arg_list[max_idx + 1 :]])
  
  print(max_all)
  
problem_description: Statement
  
  There are N children standing in a line from left to right. The activeness of
  the i-th child from the left is A_i.
  
  You can rearrange these children just one time in any order you like.
  
  When a child who originally occupies the x-th position from the left in the
  line moves to the y-th position from the left, that child earns A_x \times
  |x-y| happiness points.
  
  Find the maximum total happiness points the children can earn.
samples: [{"input": "4\n    1 3 4 2", "output": "20\n    \n\nIf we move the 1-st child from the left to the 3-rd position from the left,\nthe 2-nd child to the 4-th position, the 3-rd child to the 1-st position, and\nthe 4-th child to the 2-nd position, the children earns 1 \\times |1-3|+3\n\\times |2-4|+4 \\times |3-1|+2 \\times |4-2|=20 happiness points in total.\n\n* * *"}, {"input": "6\n    5 5 6 1 1 1", "output": "58\n    \n\n* * *"}, {"input": "6\n    8 6 9 1 2 1", "output": "85"}]