The circle line of the Berland subway has *n* stations. We know the distances between all pairs of neighboring stations:
-  *d*<sub class="lower-index">1</sub> is the distance between the 1-st and the 2-nd station;-  *d*<sub class="lower-index">2</sub> is the distance between the 2-nd and the 3-rd station;...-  *d*<sub class="lower-index">*n* - 1</sub> is the distance between the *n* - 1-th and the *n*-th station;-  *d*<sub class="lower-index">*n*</sub> is the distance between the *n*-th and the 1-st station.
The trains go along the circle line in both directions. Find the shortest distance between stations with numbers *s* and *t*.
The first line contains integer *n* (3 ≤ *n* ≤ 100) — the number of stations on the circle line. The second line contains *n* integers *d*<sub class="lower-index">1</sub>, *d*<sub class="lower-index">2</sub>, ..., *d*<sub class="lower-index">*n*</sub> (1 ≤ *d*<sub class="lower-index">*i*</sub> ≤ 100) — the distances between pairs of neighboring stations. The third line contains two integers *s* and *t* (1 ≤ *s*, *t* ≤ *n*) — the numbers of stations, between which you need to find the shortest distance. These numbers can be the same.

The numbers in the lines are separated by single spaces.
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n",
      "2 3 4 9\n",
      "1 3\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "n=int(input())\n",
    "\n",
    "Dist=input().split()\n",
    "num=input().split()\n",
    "\n",
    "s=int(num[0])\n",
    "t=int(num[1])\n",
    "\n",
    "\n",
    "Dist2=[]\n",
    "\n",
    "for i in range(n):\n",
    "    Dist2.append(int(Dist[i]))\n",
    "    \n",
    "#print(n)\n",
    "#print(Dist2)\n",
    "\n",
    "ans1=0\n",
    "ans2=0\n",
    "ans=0\n",
    "\n",
    "if s == t:\n",
    "    ans=0\n",
    "else:\n",
    "    a=min(s,t)\n",
    "    b=max(s,t)\n",
    "    \n",
    "for i in range(a-1,b-1):\n",
    "    ans1=ans1+Dist2[i]\n",
    "for i in range(b-1,n):\n",
    "    ans2=ans2+Dist2[i]\n",
    "\n",
    "ans=min(ans1,ans2)\n",
    "\n",
    "print(ans)   \n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
