#include <bits/stdc++.h>
unsigned long long gcd(unsigned long long a, unsigned long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
unsigned long long lcd(unsigned long long a, unsigned long long b) {
  if (a % b == 0) return a;
  return a / gcd(a, b) * b;
}
unsigned long long lcd(unsigned long long a, unsigned long long b,
                       unsigned long long c) {
  unsigned long long l = lcd(a, b);
  return c * l / gcd(c, l);
}
unsigned long long lcd(unsigned long long a, unsigned long long b,
                       unsigned long long c, unsigned long long d) {
  unsigned long long l = lcd(a, b, c);
  return d * l / gcd(d, l);
}
bool isOdd(int a) { return a & 1; }
bool isEven(int a) { return !isOdd(a); }
unsigned long long binominal(long long fromN, long long toK) {
  unsigned long long res = 1;
  while (fromN > toK) {
    res *= fromN--;
  }
  while (toK > 0) res /= toK--;
  return res;
}
template <typename T, typename F>
int count_if_n(T val, size_t n, F f) {
  size_t count = 0;
  for (int i = 0; i < n; ++i) {
    if (f(*val)) ++count;
    if (i != n) ++val;
  }
  return count;
}
template <typename T, typename F>
int read_count_if_n(F f) {
  size_t size;
  std::cin >> size;
  return count_if_n(std::istream_iterator<T>(std::cin), size, f);
}
template <typename T, typename F>
int read_count_if_n(size_t n, F f) {
  return count_if_n(std::istream_iterator<T>(std::cin), n, f);
}
template <typename T = int>
std::vector<T> read_vector(size_t n = 0) {
  if (n == 0) std::cin >> n;
  std::vector<T> ret(n);
  std::copy_n(std::istream_iterator<T>(std::cin), n, ret.begin());
  return ret;
}
int MaxOnes(const std::string &s, size_t current, bool Changing = false) {
  if (current == 0) {
    if (Changing) return 1;
    return static_cast<int>(s[0] == '0');
  }
  static std::unordered_map<size_t, int> withChanging, withoutChanging;
  int ret;
  if (Changing) {
    auto found = withChanging.find(current);
    if (found != withChanging.end()) return found->second;
    int contChange = MaxOnes(s, current - 1, Changing) + (s[current] == '0');
    int interruptChange = std::count(s.begin(), s.begin() + (current + 1), '1');
    ret = std::max(contChange, interruptChange);
    withChanging[current] = ret;
  } else {
    auto found = withoutChanging.find(current);
    if (found != withoutChanging.end()) return found->second;
    ret = MaxOnes(s, current - 1, false) + (s[current] == '1');
    if (s[current] == '0')
      ret = std::max(ret, MaxOnes(s, current - 1, true) + 1);
    withoutChanging[current] = ret;
  }
  return ret;
}
unsigned long long numQuad(unsigned long long a, unsigned long long b) {
  auto min = std::min(a, b);
  auto max = a + b - min;
  if (a == 0 || b == 0) return 0;
  return max / min + numQuad(max % min, min);
}
int numLines(int n, int a, int b, int c) {
  if (n < 0) return std::numeric_limits<int>::min();
  if (n == 0) return 0;
  static int res[4001]{};
  if (res[n] != 0) return res[n];
  return (res[n] =
              (std::max({numLines(n - a, a, b, c), numLines(n - b, a, b, c),
                         numLines(n - c, a, b, c)}) +
               1));
}
std::string Int2Alpha(const std::string &s) {
  int i = std::stoi(s) - 1;
  std::string res;
  while (i >= 0) {
    res += 'A' + i % 26;
    i /= 26;
    i -= 1;
  }
  std::reverse(res.begin(), res.end());
  return res;
}
std::string Alpha2Int(const std::string &s) {
  int res = 0;
  for (char c : s) {
    res = res * 26 + c - 'A' + 1;
  }
  return std::to_string(res);
}
unsigned long long numDigits(unsigned long long x) {
  if (x < 10) return x;
  return numDigits(x / 10) * 10 + 2 * (x % 10) * x / 10 + x / 10;
}
char Get(const std::string &s, int i) {
  if (i >= s.size() || i < 0) return ' ';
  return s[i];
}
char Get(const std::vector<std::string> &v, int i, int j) {
  if (i >= v.size() || i < 0) return ' ';
  return Get(v[i], j);
}
std::vector<int> GenEratosphen(size_t n) {
  std::vector<bool> simples(n);
  simples[0] = simples[1] = true;
  int numPrimes = 0;
  for (int i = 2; i < 1000; ++i) {
    if (!simples[i]) {
      numPrimes += 1;
      for (int j = i * i; j < n; j += i) simples[j] = true;
    }
  }
  std::vector<int> out;
  out.reserve(numPrimes);
  for (int i = 2; i < n; ++i) {
    if (!simples[i]) out.push_back(i);
  }
  return out;
}
std::unordered_set<unsigned long long> GenEratosphen() {
  static char simples[1000000]{};
  simples[0] = simples[1] = true;
  int numPrimes = 0;
  for (int i = 2; i < 1000; ++i) {
    if (!simples[i]) {
      numPrimes += 1;
      for (int j = i * i; j < 1000000; j += i) simples[j] = true;
    }
  }
  std::unordered_set<unsigned long long> out;
  out.reserve(numPrimes);
  for (unsigned long long i = 2; i < 1000000; ++i) {
    if (!simples[i]) out.emplace(i * i);
  }
  return out;
}
int main() {
  using namespace std;
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> distances(n + 1);
  distances[0] = 0;
  for (int i = 1; i <= n; ++i) {
    int d;
    cin >> d;
    distances[i] = distances[i - 1] + d;
  }
  int p, q;
  cin >> p >> q;
  int dist1 = abs(distances[q - 1] - distances[p - 1]);
  cout << min(dist1, distances[n] - dist1) << endl;
}

### Prompt

Create a solution in Cpp for the following problem:

The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations:

  * d1 is the distance between the 1-st and the 2-nd station;
  * d2 is the distance between the 2-nd and the 3-rd station;

...

  * dn - 1 is the distance between the n - 1-th and the n-th station;
  * dn 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.

Input

The first line contains integer n (3 ≤ n ≤ 100) — the number of stations on the circle line. The second line contains n integers d1, d2, ..., dn (1 ≤ di ≤ 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.

Output

Print a single number — the length of the shortest path between stations number s and t.

Examples

Input

4
2 3 4 9
1 3


Output

5


Input

4
5 8 2 100
4 1


Output

15


Input

3
1 1 1
3 1


Output

1


Input

3
31 41 59
1 1


Output

0

Note

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.

### Response

```cpp
#include <bits/stdc++.h>
unsigned long long gcd(unsigned long long a, unsigned long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
unsigned long long lcd(unsigned long long a, unsigned long long b) {
  if (a % b == 0) return a;
  return a / gcd(a, b) * b;
}
unsigned long long lcd(unsigned long long a, unsigned long long b,
                       unsigned long long c) {
  unsigned long long l = lcd(a, b);
  return c * l / gcd(c, l);
}
unsigned long long lcd(unsigned long long a, unsigned long long b,
                       unsigned long long c, unsigned long long d) {
  unsigned long long l = lcd(a, b, c);
  return d * l / gcd(d, l);
}
bool isOdd(int a) { return a & 1; }
bool isEven(int a) { return !isOdd(a); }
unsigned long long binominal(long long fromN, long long toK) {
  unsigned long long res = 1;
  while (fromN > toK) {
    res *= fromN--;
  }
  while (toK > 0) res /= toK--;
  return res;
}
template <typename T, typename F>
int count_if_n(T val, size_t n, F f) {
  size_t count = 0;
  for (int i = 0; i < n; ++i) {
    if (f(*val)) ++count;
    if (i != n) ++val;
  }
  return count;
}
template <typename T, typename F>
int read_count_if_n(F f) {
  size_t size;
  std::cin >> size;
  return count_if_n(std::istream_iterator<T>(std::cin), size, f);
}
template <typename T, typename F>
int read_count_if_n(size_t n, F f) {
  return count_if_n(std::istream_iterator<T>(std::cin), n, f);
}
template <typename T = int>
std::vector<T> read_vector(size_t n = 0) {
  if (n == 0) std::cin >> n;
  std::vector<T> ret(n);
  std::copy_n(std::istream_iterator<T>(std::cin), n, ret.begin());
  return ret;
}
int MaxOnes(const std::string &s, size_t current, bool Changing = false) {
  if (current == 0) {
    if (Changing) return 1;
    return static_cast<int>(s[0] == '0');
  }
  static std::unordered_map<size_t, int> withChanging, withoutChanging;
  int ret;
  if (Changing) {
    auto found = withChanging.find(current);
    if (found != withChanging.end()) return found->second;
    int contChange = MaxOnes(s, current - 1, Changing) + (s[current] == '0');
    int interruptChange = std::count(s.begin(), s.begin() + (current + 1), '1');
    ret = std::max(contChange, interruptChange);
    withChanging[current] = ret;
  } else {
    auto found = withoutChanging.find(current);
    if (found != withoutChanging.end()) return found->second;
    ret = MaxOnes(s, current - 1, false) + (s[current] == '1');
    if (s[current] == '0')
      ret = std::max(ret, MaxOnes(s, current - 1, true) + 1);
    withoutChanging[current] = ret;
  }
  return ret;
}
unsigned long long numQuad(unsigned long long a, unsigned long long b) {
  auto min = std::min(a, b);
  auto max = a + b - min;
  if (a == 0 || b == 0) return 0;
  return max / min + numQuad(max % min, min);
}
int numLines(int n, int a, int b, int c) {
  if (n < 0) return std::numeric_limits<int>::min();
  if (n == 0) return 0;
  static int res[4001]{};
  if (res[n] != 0) return res[n];
  return (res[n] =
              (std::max({numLines(n - a, a, b, c), numLines(n - b, a, b, c),
                         numLines(n - c, a, b, c)}) +
               1));
}
std::string Int2Alpha(const std::string &s) {
  int i = std::stoi(s) - 1;
  std::string res;
  while (i >= 0) {
    res += 'A' + i % 26;
    i /= 26;
    i -= 1;
  }
  std::reverse(res.begin(), res.end());
  return res;
}
std::string Alpha2Int(const std::string &s) {
  int res = 0;
  for (char c : s) {
    res = res * 26 + c - 'A' + 1;
  }
  return std::to_string(res);
}
unsigned long long numDigits(unsigned long long x) {
  if (x < 10) return x;
  return numDigits(x / 10) * 10 + 2 * (x % 10) * x / 10 + x / 10;
}
char Get(const std::string &s, int i) {
  if (i >= s.size() || i < 0) return ' ';
  return s[i];
}
char Get(const std::vector<std::string> &v, int i, int j) {
  if (i >= v.size() || i < 0) return ' ';
  return Get(v[i], j);
}
std::vector<int> GenEratosphen(size_t n) {
  std::vector<bool> simples(n);
  simples[0] = simples[1] = true;
  int numPrimes = 0;
  for (int i = 2; i < 1000; ++i) {
    if (!simples[i]) {
      numPrimes += 1;
      for (int j = i * i; j < n; j += i) simples[j] = true;
    }
  }
  std::vector<int> out;
  out.reserve(numPrimes);
  for (int i = 2; i < n; ++i) {
    if (!simples[i]) out.push_back(i);
  }
  return out;
}
std::unordered_set<unsigned long long> GenEratosphen() {
  static char simples[1000000]{};
  simples[0] = simples[1] = true;
  int numPrimes = 0;
  for (int i = 2; i < 1000; ++i) {
    if (!simples[i]) {
      numPrimes += 1;
      for (int j = i * i; j < 1000000; j += i) simples[j] = true;
    }
  }
  std::unordered_set<unsigned long long> out;
  out.reserve(numPrimes);
  for (unsigned long long i = 2; i < 1000000; ++i) {
    if (!simples[i]) out.emplace(i * i);
  }
  return out;
}
int main() {
  using namespace std;
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> distances(n + 1);
  distances[0] = 0;
  for (int i = 1; i <= n; ++i) {
    int d;
    cin >> d;
    distances[i] = distances[i - 1] + d;
  }
  int p, q;
  cin >> p >> q;
  int dist1 = abs(distances[q - 1] - distances[p - 1]);
  cout << min(dist1, distances[n] - dist1) << endl;
}

```