N = gets.to_i S, T = gets.split.map(&:to_i) A = gets.split.map(&:to_i) R1 = [0] R2 = [0] c1 = (T - S).abs - 1 c2 = (N - 2) - c1 if S < T 1.upto(c1) do |v| i = (S - 1 + v) % N R1 << R1.last + A[i] end 1.upto(c2) do |v| i = (S - 1) - v R2 << R2.last + A[i] end else 1.upto(c1) do |v| i = (S - 1) - v R1 << R1.last + A[i] end 1.upto(c2) do |v| i = (S - 1 + v) % N R2 << R2.last + A[i] end end x = A[S - 1] y = A[T - 1] if c1.even? && c2.even? x += R1[c1 / 2] + R2[c2 / 2] y += (R1.last - R1[c1 / 2]) + (R2.last - R2[c2 / 2]) elsif c1.even? x += R1[c1 / 2] + R2[c2 / 2 + 1] y += (R1.last - R1[c1 / 2]) + (R2.last - R2[c2 / 2 + 1]) elsif c2.even? x += R1[c1 / 2 + 1] + R2[c2 / 2] y += (R1.last - R1[c1 / 2 + 1]) + (R2.last - R2[c2 / 2]) else x1 = x + R1[c1 / 2] + R2[c2 / 2 + 1] y1 = y + (R1.last - R1[c1 / 2]) + (R2.last - R2[c2 / 2 + 1]) x2 = x + R1[c1 / 2 + 1] + R2[c2 / 2] y2 = y + (R1.last - R1[c1 / 2 + 1]) + (R2.last - R2[c2 / 2]) if x1 - y1 < x2 - y2 x, y = x2, y2 else x, y = x1, y1 end end puts x - y