output_description: Print the performance required to achieve the objective.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      R
      G
attempt: import sys
  
  input = sys.stdin.readline
  sys.setrecursionlimit(10**9)
  MOD = 10**9 + 7
  
  N = int(input())
  T = [0] + list(map(int, input().split()))
  V = [0] + list(map(int, input().split()))
  
  max_speed_from_left = [0] * (N + 1)
  max_speed_from_right = [0] * (N + 1)
  
  for i in range(1, N):
      start = max_speed_from_left[i - 1]
      max_speed_from_left[i] = min(start + T[i], V[i], V[i + 1])
  
  for i in range(N - 1, 0, -1):
      start = max_speed_from_right[i + 1]
      max_speed_from_right[i] = min(start + T[i + 1], V[i], V[i + 1])
  
  speed = [min(x, y) for x, y in zip(max_speed_from_left, max_speed_from_right)]
  
  
  def dist(left_speed, right_speed, t, v):
      x = (v - left_speed) + (v - right_speed)
      if x >= t:
          v = (left_speed + right_speed) / 2
          x = t
      d = (left_speed + v) * (v - left_speed) / 2
      d += v * (t - x)
      d += (right_speed + v) * (v - right_speed) / 2
      return d
  
  
  ans = 0
  for i in range(1, N + 1):
      ans += dist(speed[i - 1], speed[i], T[i], V[i])
  
  print(ans)
  
problem_description: Statement
  
  Takahashi is a user of a site that hosts programming contests.  
  When a user competes in a contest, the _rating_ of the user (not necessarily
  an integer) changes according to the _performance_ of the user, as follows:
  
    * Let the current rating of the user be a.
    * Suppose that the performance of the user in the contest is b.
    * Then, the new rating of the user will be the avarage of a and b.
  
  For example, if a user with rating 1 competes in a contest and gives
  performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
  
  Takahashi's current rating is R, and he wants his rating to be exactly G after
  the next contest.  
  Find the performance required to achieve it.
samples: [{"input": "2002\n    2017", "output": "2032\n    \n\nTakahashi's current rating is 2002.  \nIf his performance in the contest is 2032, his rating will be the average of\n2002 and 2032, which is equal to the desired rating, 2017.\n\n* * *"}, {"input": "4500\n    0", "output": "-4500\n    \n\nAlthough the current and desired ratings are between 0 and 4500, the\nperformance of a user can be below 0."}]