CF278A Circle Line

题目描述

有$n$个车站排成一个环形,给定$n$个车站之间的距离,求从第$s$个车站到第$t$个车站所需的最短距离。

输入格式

第一行给定车站个数$n$。 第二行给定$n$个车站之间的距离,其中第$i$个数表示第$i$个车站到第$i+1$个车站的距离$d_{i}$。特别地,最后一个数表示第一个车站与最后一个车站之间的距离。 第三行给定两个整数$s$和$t$,表示起点和终点。

输出格式

输出共一行,表示第$s$个车站到第$t$个车站之间的最短距离。

说明/提示

In the first sample the length of path $ 1→2→3 $ equals 5, the length of path $ 1→4→3 $ equals 13. In the second sample the length of path $ 4→1 $ is 100, the length of path $ 4→3→2→1 $ is 15. In the third sample the length of path $ 3→1 $ is 1, the length of path $ 3→2→1 $ is 2. In the fourth sample the numbers of stations are the same, so the shortest distance equals 0.