output_description: Find the minimum possible absolute difference of the maximum and the minimum
  among P,Q,R,S.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 A_2 ... A_N
attempt: n = int(input())
  a = input().split()
  a = [int(m) for m in a]
  asum = []
  t = 0
  for i in range(n):
      t += a[i]
      asum.append(t)
  x1 = 0
  x2 = 0
  x3 = 0
  x4 = 0
  s1 = 1
  s2 = 3
  ansli = []
  for i in range(n - 3):
      ansli.append([])
  ac = 2
  bc = 2
  for i in range(2, n - 1):
      for j in range(s1, i):
          if j == 1:
              s1l = asum[0]
              s1r = asum[i - 1] - asum[0]
              cr = abs(s1l - s1r)
              ac = 2
          else:
              if ac == 1:
                  s1r += a[i - 1]
                  cr = abs(s1l - s1r)
  
              s1l2 = asum[j - 1]
              s1r2 = asum[i - 1] - asum[j - 1]
              cr2 = abs(s1l2 - s1r2)
              if cr2 <= cr:
                  s1l = s1l2
                  s1r = s1r2
                  cr = cr2
                  s1 = j
                  ac = 2
              else:
                  break
      ansli[i - 2].append(s1l)
      ansli[i - 2].append(s1r)
      ac = 1
      for k in range(s2, n):
          if k == 3:
              s2l = asum[i] - asum[i - 1]
              s2r = asum[n - 1] - asum[i]
              crw = abs(s2l - s2r)
              bc = 2
          else:
              if bc == 1:
                  s2l -= a[i - 1]
                  crw = abs(s2l - s2r)
  
              s2l2 = asum[k - 1] - asum[i - 1]
              s2r2 = asum[n - 1] - asum[k - 1]
              cr2w = abs(s2l2 - s2r2)
              if cr2w <= crw:
                  s2l = s2l2
                  s2r = s2r2
                  crw = cr2w
                  s2 = k
                  bc = 2
              else:
                  break
      ansli[i - 2].append(s2l)
      ansli[i - 2].append(s2r)
      bc = 1
  ransli = []
  for i in range(n - 3):
      p = max(ansli[i])
      q = min(ansli[i])
      ransli.append(p - q)
  
  print(min(ransli))
  
problem_description: Statement
  
  Snuke has an integer sequence A of length N.
  
  He will make three cuts in A and divide it into four (non-empty) contiguous
  subsequences B, C, D and E. The positions of the cuts can be freely chosen.
  
  Let P,Q,R,S be the sums of the elements in B,C,D,E, respectively. Snuke is
  happier when the absolute difference of the maximum and the minimum among
  P,Q,R,S is smaller. Find the minimum possible absolute difference of the
  maximum and the minimum among P,Q,R,S.
samples: [{"input": "5\n    3 2 4 1 2", "output": "2\n    \n\nIf we divide A as B,C,D,E=(3),(2),(4),(1,2), then P=3,Q=2,R=4,S=1+2=3. Here,\nthe maximum and the minimum among P,Q,R,S are 4 and 2, with the absolute\ndifference of 2. We cannot make the absolute difference of the maximum and the\nminimum less than 2, so the answer is 2.\n\n* * *"}, {"input": "10\n    10 71 84 33 6 47 23 25 52 64", "output": "36\n    \n\n* * *"}, {"input": "7\n    1 2 3 1000000000 4 5 6", "output": "999999994"}]