output_description: Print the minimum positive integer divisible by both 2 and N.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
attempt: # 整数列A
  # 3箇所で切って、４つに
  # それぞれの総和の最大値と最小値の差の絶対値の最小値
  
  # 中央を固定することを考える(結局、その固定を全検索するが)
  # 中央固定後、左側について、両方が同じくらいの値になるのが最適と考えて良いらしい
  
  from itertools import accumulate
  
  N = int(input())
  A = list(map(int, input().split()))
  SumA = list(accumulate(A))
  
  tmpP = tmpQ = tmpR = tmpS = 0
  P = Q = R = S = 0
  ans = 10e9
  l = 0
  r = 2
  
  # midとmid+1の間が中間の切断
  for mid in range(1, N - 2):
  
      # l,rは、単調増加であるため、全ての中間点を求めるループの間、クリアの必要がないらしい
  
      # 次のやつよりも、今のやつの方が大きい限り、継続
      # 必ず、それが逆転する時が最小のはず、という考え。。。
      while l < mid and abs((SumA[mid] - SumA[l + 1]) - SumA[l + 1]) < abs(
          (SumA[mid] - SumA[l]) - SumA[l]
      ):
          l += 1
  
      # 次のやつよりも、今のやつの方が大きい限り、継続
      # 必ず、それが逆転する時が最小のはず、という考え。。。
      while r < N - 1 and abs(
          (SumA[N - 1] - SumA[r + 1]) - (SumA[r + 1] - SumA[mid])
      ) < abs((SumA[N - 1] - SumA[r]) - (SumA[r] - SumA[mid])):
          r += 1
  
      # print("{},{}".format(mid,l))
  
      P = SumA[l]
      Q = SumA[mid] - SumA[l]
      R = SumA[r] - SumA[mid]
      S = SumA[N - 1] - SumA[r]
  
      # print(P,Q,R,S)
      diff = max(P, Q, R, S) - min(P, Q, R, S)
      diff = abs(diff)
      ans = min(ans, diff)
  
  print(ans)
  
problem_description: Statement
  
  You are given a positive integer N. Find the minimum positive integer
  divisible by both 2 and N.
samples: [{"input": "3", "output": "6\n    \n\n6 is divisible by both 2 and 3. Also, there is no positive integer less than 6\nthat is divisible by both 2 and 3. Thus, the answer is 6.\n\n* * *"}, {"input": "10", "output": "10\n    \n\n* * *"}, {"input": "999999999", "output": "1999999998"}]