CF515E Drazil and Park

Description

Drazil is a monkey. He lives in a circular park. There are $ n $ trees around the park. The distance between the $ i $ -th tree and ( $ i+1 $ )-st trees is $ d_{i} $ , the distance between the $ n $ -th tree and the first tree is $ d_{n} $ . The height of the $ i $ -th tree is $ h_{i} $ . Drazil starts each day with the morning run. The morning run consists of the following steps: - Drazil chooses two different trees - He starts with climbing up the first tree - Then he climbs down the first tree, runs around the park (in one of two possible directions) to the second tree, and climbs on it - Then he finally climbs down the second tree. But there are always children playing around some consecutive trees. Drazil can't stand children, so he can't choose the trees close to children. He even can't stay close to those trees. If the two trees Drazil chooses are $ x $ -th and $ y $ -th, we can estimate the energy the morning run takes to him as $ 2(h_{x}+h_{y})+dist(x,y) $ . Since there are children on exactly one of two arcs connecting $ x $ and $ y $ , the distance $ dist(x,y) $ between trees $ x $ and $ y $ is uniquely defined. Now, you know that on the $ i $ -th day children play between $ a_{i} $ -th tree and $ b_{i} $ -th tree. More formally, if $ a_{i}

Input Format

N/A

Output Format

N/A