jiahuimbzuai/CoQuIR huggingface dataset:
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    func count() -> Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
}
extension Array where Element: Comparable {
    func max() -> Element! {
        return self.maxElement()
    }
    func min() -> Element! {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
var ans = 0
var p = [Int]()
for _ in 0..<N {
    p += [readInt()!]
}
print(p.reduce(0){$0+$1}-p.max()!/2)
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    func count() -> Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
}
extension Array where Element: Comparable {
    func max() -> Element! {
        return self.maxElement()
    }
    func min() -> Element! {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
var ans = 0
var maxP = 0
for _ in 0..<N {
    let p = readInt()!
    ans += p
    maxP = max(p, maxP)
}
print(ans-maxP/2)
//  [swift]
var t: String? = readLine()
var t2: String = t!
var n = Int(t2)!

var maxi = Int.min
var ans = 0
for _ in 0..<n{
    var u: String? = readLine()
    var u2: String = u!
    var p = Int(u2)!
    maxi = max(maxi, p)
    ans += p
}

ans -= maxi / 2
print(ans)
//  [swift]
let N = Int(readLine()!)!
var p: [Int] = (1...N).map { _ in Int(readLine()!)! }
p.sort()
print(p[..<(N-1)].reduce(0, +) + p[N-1] / 2)
//  [typescript]
const funcB = (input: string): void => {
    const hoge: number[] = input.trim().slice(1).split(/\n/).map(Number);
    const hogeSum: number = hoge.reduce((a, x) => a+=x, 0);
    const hogeDis: number = Math.max(...hoge) / 2;
    console.log(hogeSum - hogeDis);
}

funcB(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let n=t.n()
  let nr=t.n(n)
  let max=t.max(...nr)
  
  t.o(nr.reduce((t,d)=>{return t+d})-(max/2))
}
main()
//  [typescript]
function main(input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const ps = input.slice(1).map(n => Number(n));
  let result = 0;
  let max = 0;
  for (let i = 0; i < n; i++) {
  	const p = ps[i];
    result += p;
    if (max < p) {
      max = p;
    }
  }
  result -= max/2;
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
'use strict';

const receive = require('fs')
  .readFileSync('/dev/stdin', 'utf8')
  .split(/\s/);

const main = input => {
  const [n, ...p] = input.map(x => Number(x)); // 改行が変換されてできた0が交じるが問題ないので無視
  p.sort((x, y) => y - x);
  p[0] /= 2;
  const ans = p.reduce((x, y) => x + y);
  console.log(ans);
};

main(receive);
//  [typescript]
const main = (input: string) => {
  const lines = input.trim().split("\n");
  const P = lines.slice(1).map(str => parseInt(str))
  const MaxPrice = Math.max(...P)
  let sum = 0;

  P.forEach(p => {
    sum += p
  });

  console.log(sum - (MaxPrice / 2))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
import * as fs from 'fs';

namespace AtCoder.abc115 {

    class Program {
        /**
         * in
         *  3
         *  4980
         *  7980
         *  6980
         * out
         *  15950
         */
        main(inp: string): void {

            const p = inp.split('\n');
            p.shift();

            const sorted: string[] = p.sort((a, b) => {
                return parseInt(b) - parseInt(a);
            });
            const sortedNum: number[] = sorted.map(Number);

            const ans: number = sortedNum.reduce(
                (accumulator, currentValue, idx) =>
                    idx === 0 ? (accumulator + currentValue) / 2 : accumulator + currentValue, 0);
            console.log(ans);
        }
    }

    const prg = new Program();
    prg.main(fs.readFileSync('/dev/stdin', 'utf8').trim());
}
//  [python]
a,b,x = map(int, input().split())

min_ = a//x + (1 if a%x!=0 else 0)
max_ = b//x

print(max_-min_+1)
//  [python]
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


def main():
    a, b, x = map(int, input().split())
    if(a % x == 0):
        print(b // x - a // x + 1)
    else:
        print(b//x - a//x)
    

    

if __name__ == '__main__':
    main()
//  [python]
import itertools
import math
import sys
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
import sys
sys.setrecursionlimit(4100000)
from functools import lru_cache
INF = 1 << 60

#ここから書き始める
a, b, x = map(int, input().split())
print(b // x - (a - 1) // x)
//  [java]
import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		long a = Long.parseLong(str[0]);
		long b = Long.parseLong(str[1]);
		long x = Long.parseLong(str[2]);
		long ans1 = a / x;
		long ans2 = b / x;
		if(a%x!=0){
			System.out.println(ans2-ans1);
		}else{
			System.out.println(ans2-ans1+1);
		}
	}
}
//  [java]
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long a = in.nextLong();
            long b = in.nextLong();
            long x = in.nextLong();

            if (a == 0) {
                out.println(b / x + 1);
            } else {
                out.println(b / x - (a - 1) / x);
            }
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}
//  [java]
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        BigInteger a = sc.nextBigInteger();
        BigInteger b = sc.nextBigInteger();
        BigInteger x = sc.nextBigInteger();

        BigInteger n = b.divide(x).subtract(a.subtract(BigInteger.ONE).divide(x));

        if(a.compareTo(BigInteger.ZERO) == 0 && x.compareTo(BigInteger.ONE) != 0) n = n.add(BigInteger.ONE);
        System.out.println(n);
    }
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<ctype.h>

typedef long long ll;

ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll max(ll a, ll b) { return (a > b) ? a : b; }

ll min(ll a, ll b) { return (a < b) ? a : b; }

ll asc(const void* a, const void* b) { return *(ll*)a - *(ll*)b; }

ll dsc(const void* a, const void* b) { return *(ll*)b - *(ll*)a; }

bool flag;

ll f(ll x,ll y) {
	if (x == -1) return -1;
	else return x / y;
}

int main() {
	ll n,a, b;
	scanf("%lld%lld%lld", &a,&b,&n);
	printf("%lld", f(b,n)-f(a-1,n));
	
	return 0;
}
//  [c]
#include<stdio.h>

int main(){
    long long int a,b,x;
    scanf("%lld%lld%lld",&a,&b,&x);

    long long int sum;
    if(a%x==0){
        sum=(b/x)-(a/x)+1;
    }else{
        sum=(b/x)-(a/x);
    }
    printf("%lld\n",sum);
    return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	int i;
	long long int a, b, x;
	long long int ans;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	a = atoll(ch);
	ch = strtok(NULL, " ");
	b = atoll(ch);
	ch = strtok(NULL, " ");
	x = atoll(ch);

	ans = (b / x) + 1;
	if(a != 0) {
		ans -= ((a - 1) / x) + 1;
	}

	printf("%lld\n", ans);

	return 0;
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner((os.Stdin))

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	l := nextLine()
	i, e := strconv.Atoi(l)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, x := nextInt(), nextInt(), nextInt()

	fmt.Printf("%d\n", ABC048B(a, b, x))
}

// ABC048B ...
func ABC048B(a, b, x int) int {
	if a == 0 {
		return b/x - (a)/x + 1
	}
	return b/x - (a-1)/x
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var a, b, x int
	fmt.Scanf("%d %d %d", &a, &b, &x)

	fmt.Printf("%d\n", divisibleUpto(x, b)-divisibleUpto(x, a-1))
}

func divisibleUpto(x, n int) int {
	if n == -1 {
		return 0
	}
	return n/x + 1
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b, x := iScan(), iScan(), iScan()
	if a == 0 {
		fmt.Println(b/x + 1)
	} else {
		fmt.Println(b/x - (a-1)/x)
	}
}
//  [ruby]
A,B,X = `dd`.split.map(&:to_i)
p B/X + 1 - (A > 0 ? (A-1)/X + 1 : 0)
//  [ruby]
a, b, x = gets.chomp.split(" ").map(&:to_i)
puts  b / x - (a-1) / x
//  [ruby]
a,b,x = gets.chomp.split.map &:to_i

a_div = (a - 1) / x
b_div = b / x

puts b_div - a_div
//  [rust]
#![allow(dead_code,unused_variables,unused_imports)]
use proconio::{fastout, input};
use proconio::marker::Chars;
use std::cmp::max;

#[fastout]
fn main() {
    input!{
        a:usize,
        b:usize,
        x:usize,
    }

    let n_max : i64 = (b/x) as i64;
    let n_min : i64 = if a == 0 { -1 } else {((a - 1)/x) as i64}; 

    println!("{}",n_max-n_min);

}
//  [rust]
use proconio::input;

fn main() {
    input! {
        a: usize,
        b: usize,
        x: usize
    }

    let ans = if a % x == 0 { b/x - a/x + 1 } else { b/x - a/x };

    println!("{}",ans)
    
}
//  [rust]
fn main() {
    proconio::input! {
        a: usize,
        b: usize,
        x: usize,
    }
    let ans = if a == 0 { 1 } else { 0 } + b / x - if a == 0 { 0 } else { (a - 1) / x };
    println!("{}", ans);
}
//  [swift]
import Foundation

extension String {
    
    func toStrList() -> [String] {
        return self.map{String($0)}
    }
    
    func toIntList() -> [Int] {
        return self.map{Int(String($0))!}
    }
    
    func toSepDoubleList() -> [Double]{
        return self.split(separator: " ").map{Double($0)!}
    }

    func toSepIntList() -> [Int] {
        return self.split(separator: " ").map{Int($0)!}
    }

    func toSepStrList() -> [String] {
        return self.split(separator: " ").map{String($0)}
    }
    
    func zFill(n:Int) -> String {
        return String(format: "%0\(n)d", Int(self)!)
    }
    
    func count(c:Character) -> Int{
        var result = 0

        for e in self{
            if e == c{
                result += 1
            }
        }
        return result
    }

    func counter() -> Dictionary<Character, Int>{
        var result:[Character:Int] = [:]
        
        for c in self{
            guard let _ = result.index(forKey: c) else {
                result[c] = 1
                continue
            }
            result[c]! += 1
        }
        return result
    }
}

extension Int {
    func toBin() -> String {
        return String(self, radix: 2)
    }
    
    func toNBin(_ radix:Int) -> String{
        return String(self, radix: radix)
    }
    
    func toD() -> Double {
        return Double(self)
    }
}

extension Double {
    func toI() -> Int {
        return Int(self)
    }
}

extension Array where Element: Equatable{
    func count(n:Self.Element) -> Int{
        var result = 0
        for e in self{
            if e == n{
                result += 1
            }
        }
        return result
    }
}

func pow(_ base:Int,_ exp:Int) -> Int{
    let d = pow(base.toD(), exp.toD())
    return Int(d)
}


func abc048b() -> Int{
    let abx = readLine()!.toSepIntList()
    let bx = abx[1] / abx[2]
    let ax = abx[0] / abx[2]
    if abx[0] % abx[2] == 0 {
        return bx - ax + 1
    } else {
        return bx - ax
    }
}

print(abc048b())
//  [swift]
let i=readLine()!.characters.split(" ").map{Int(String($0))!};print(i[1]/i[2]-(i[0]-1)/(i[0]>0 ?i[2]:1))
//  [typescript]
{
  const Main = (input: string) => {
    const [a,b,x] = input.trim().split(" ").map(BigInt)
    if (a === 0n) {
      console.log((b / x + 1n).toString())
    } else {
      console.log((b / x - (a - 1n) / x).toString())
    }
  };

  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}
//  [python]
import numpy as np

N = int(input())  
B = np.array(input().split(), dtype=np.int64)

ans = 0
ans += B[0] + B[N-2]

for i in np.arange(N-2):
    ans += np.min(np.array([B[i], B[i+1]]))
    
print(int(ans))
//  [python]
import numpy as np

N = int(input())
B = list( map(int,input().split()) )

A = np.zeros(N,dtype=int)
A[0] = B[0]
A[-1] = B[-1]

if N == 2:
    print(A.sum())
    exit(0)

for i in range(len(B)-1):
    A[i+1] = min(B[i],B[i+1])

print(A.sum())
//  [python]
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )
# from itertools import accumulate
# from collections import deque

import random


def main():
    n=int(input())
    b = list(map(int, input().split()))
    
    sum=0
    sum+=b[0]
    sum+=b[n-2]
    for i in range(n-2):
        sum+=min(b[i],b[i+1])
    print(sum)
    return

if __name__ == '__main__':
    main()
//  [java]
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        scanner.nextLine();

        final int[] b = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        int sum = b[0];
        for (int i = 0; i < n - 2; i++) {
            sum += Math.min(b[i], b[i + 1]);
        }
        sum += b[b.length - 1];

        System.out.println(sum);
    }
}
//  [java]
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int a[] = new int[n];
		a[0] = sc.nextInt();

		int curentInt = a[0];
		int beforeCur = curentInt;
		for(int i = 1;i < (n - 1);i++) {
			curentInt = sc.nextInt();
			a[i] = (beforeCur > curentInt) ? curentInt :beforeCur;
			beforeCur = curentInt;
		}

		a[n - 1] = curentInt;

		long sum = java.util.Arrays.stream(a).sum();
		System.out.println(sum);
	}
}
//  [java]
import java.util.*;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n - 1];
        for (int i = 0; i < n - 1; i++) {
            b[i] = sc.nextInt();
        }
        a[0] = b[0];
        for (int i = 1; i < n - 1; i++) {
            a[i] = Integer.min(b[i - 1], b[i]);
        }
        a[n - 1] = b[n - 2];
        System.out.println(IntStream.of(a).sum());
    }
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, r, p;
string s, t;
// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	vll a(n);
	vll ans(n,0);
	for(ll i=1;i<n;i++) cin>>a[i];

	ans[0] = a[1];

	for(ll i=1;i<n-1;i++) ans[i] = min(a[i],a[i+1]);

	ans[n-1] = a[n-1];
	cout<<accumulate(all(ans),0);
}

int main() {
	fastio; randomINT;
	//cin>>t;
	while (T--) {
		MAIN();
	}
	return 0;
}
//  [c]
#include<stdio.h>

int min(int a, int b){
    if(a > b){
        return b;
    }else{
        return a;
    }
}

int main(void){
    int n, s;
    int b[100];

    scanf("%d", &n);
    for(int i = 0; i < n - 1; i++) scanf("%d", &b[i]);

    s =  b[0] + b[n - 2];
    for(int i = 0; i < n - 2; i++) s += min(b[i], b[i+1]);

    printf("%d\n", s);

    return 0;
}
//  [c]
#include <stdio.h>

int min(int a,int b);

int main(void)
{
    int n=0,sum=0;
    int b[101]={};
    scanf("%d",&n);
    for(int i=0;i<n-1;i++) scanf("%d",&b[i]);
    sum+=b[0]+b[n-2];
    for(int i=0;i<n-1;i++){
        sum+=min(b[i],b[i+1]);
    }
    printf("%d",sum);
    return 0;
}

int min(int a,int b){
    return a<b?a:b;
}
//  [c]
#include<stdio.h>
int main(){
  long long int N;
  scanf("%lld",&N);
  long long int B[N-1];
  int i;
  for(i=0;i<N-1;i++)
    scanf("%lld",&B[i]);
  long long int A[N];
  A[0] = B[0];
  for(i=1;i<N;i++)
    A[i]=B[i-1];
  for(i=0;i<N-1;i++){
    if(B[i]<A[i])
      A[i]=B[i];
    if(B[i]<A[i+1])
      A[i]=B[i+1];
  }
  long long int sum=0;
  for(i=0;i<N;i++)
    sum=sum+A[i];
  printf("%lld",sum);
  return 0;
}
//  [javascript]
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var b = o.l();
  var ans = b[0]+b[n-2];
  for(var i = 1; i < n-1; i++){
    ans += Math.min(b[i-1],b[i])
  }
  return ans;
}
//  [javascript]

function Main(arg) {
 
    var N = arg.split("\n")[0] - 0;
    var B = arg.split("\n")[1].split(" ");
    B.unshift(B[0]);

    var ans = 0;
    for (var i = 0; i < N-1; i++){
        if (B[i]-0 > B[i + 1]-0) {
            B[i] = B[i + 1];
        }
    }

    for (var i = 0; i < N; i++){
        ans += (B[i] - 0);
    }

    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const list = lines[1].split(" ").map(v=>v-0);
    let ans = 0;
    for(let i=0;i<list.length-1;i++){
        ans+=Math.min(list[i],list[i+1])
    }
    ans += list[list.length-1] + list[0];
    console.log(ans);
});
//  [go]
package main
 
import(
  "fmt"
	"bufio"
	"os"
	"strings"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func Rr() []string {
  sc.Scan()
  slice := strings.Split(sc.Text(), " ")
  return slice
}
 
func abc140c(N int){
	sum := 0
	now := 0
	bef := 0
	for i := 0; i < N; i++{
		if i != N-1 {
		fmt.Scan(&now)
		}
		if i == 0{
			sum += now
		}else if i == N-1{
			sum+=bef
		}else{
			if now < bef{
				sum+=now
			}else{
				sum+=bef
			}
		}
		bef = now
	}
	fmt.Println(sum)
}	
 
func main(){
	x := 0
	fmt.Scan(&x)
	abc140c(x)
}
//  [ruby]
gets.to_i
ary = gets.split.map(&:to_i)
ans = ary.first

(0...ary.size - 1).each { |i| ans += [ary[i], ary[i + 1]].min }

puts ans + ary.last
//  [ruby]
n = gets.to_i
num = gets.strip.split.map(&:to_i)
ary = Array.new(n,0)
ary[0] = num[0]
ary[n-1] = num[n-2]
i = 1
if n != 2
  while i < n-1 do
    if num[i-1] >= num[i]
      ary[i] = num[i]
    else
      ary[i] = num[i-1]
    end
    i += 1
  end
end
puts ary.sum
//  [ruby]
n = gets.to_i
b = gets.split.map &:to_i
a = Array.new(n, 10**5)
for i in 0...n-1
  a[i] = [a[i], b[i]].min
  a[i+1] = [a[i+1], b[i]].min
end
p a.sum
//  [rust]
fn main() {
    let n: usize = read_line_as_value();
    let b_in: Vec<usize> = read_line_as_vector();

    let mut prev = b_in[n-2];
    let mut ans = 0;
    for i in (0..n-1).rev() {
        ans += std::cmp::min(b_in[i], prev);
        prev = b_in[i];
    }
    ans += prev;
    println!("{}", ans);
}

fn read_line_as_value<T: std::str::FromStr>() -> T {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().parse() {
        Ok(val) => val,
        _ => panic!("error while parsing input: {}", input)
    }
}

fn read_line_as_vector<T: std::str::FromStr>() -> Vec<T> {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().split_whitespace().map(|x| x.parse()).collect::<Result<Vec<T>, _>>() {
        Ok(vec) => vec,
        _ => panic!("error while parsing input: {}", input)
    }
}
//  [rust]
use proconio::input;

fn main() {
    input! {
        n: usize,
        b: [i64; n - 1],
    };
    let mut ans = b[0] + b[n - 1 - 1];
    for (b_i0, b_i1) in b.windows(2).map(|w| match w {
        &[b_i0, b_i1] => (b_i0, b_i1),
        _ => unreachable!(),
    }) {
        ans += std::cmp::min(b_i0, b_i1);
    }
    println!("{}", ans);
}
//  [swift]
let n=Int(readLine()!)!
let b=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

var a : [Int] = []

a.append(b[0])

var i = 0

for i in 1..<n - 1 {
  a.append( min( b[i-1], b[i] ) )
}

a.append(b[n-2])
//print( a )
print( a.reduce(0, combine: + ) )
//  [typescript]
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): any => {
  let tmp = ``
  const N = +lines[0]
  const Bn = lines[1].split(` `).map(num => +num)
  const obj = { N, Bn }
  debug(obj)
  return obj
}

// solver
export const solve = (lines: string[]): string => {
  const { N, Bn } = parseLines(lines)

  let sum = Bn[0];
  let tmp = Bn[0];
  for(let i = 1; i < N - 1; i++) {
    sum += tmp < Bn[i] ? tmp : Bn[i]
    tmp = Bn[i]
  }
  sum += tmp
  return `${sum}`
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}
//  [typescript]
import * as readline from 'readline';
const rl = readline.createInterface(process.stdin, process.stdout);

let line = 0;
let n: number;
let a: number[] = [];
let b: number[];

rl.on("line", input => {
  line++;
  if (line === 1) {
    n = parseInt(input);
    a.length = n;
    for (let i = 0; i < n-1; i++) a[i] = 0;
  } else {
    b = input.split(/\s+/).map(val=>parseInt(val));
    a[0] = b[0];
    for (let i = 0; i < n-1; i++) {
      a[i+1] = b[i];
      if (a[i] > b[i]) a[i] = b[i];
    }
    let x = 0;
    for (let i = 0; i < n; i++) {
      x += a[i];
    }
    console.log(x);
  }
});
//  [typescript]
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): { N: number, B: number[] } => {
  const N = +lines[0]
  const B = lines[1].split(' ').map(line => +line)
  const obj = { N, B }
  debug(obj)
  return obj
}
// solver
export const solve = (lines: string[]): string => {
  const { N, B } = parseLines(lines)
  const A = [B[0]]
  for (let i = 1; i < N; i++) {
    if (B[i] === undefined) {
      A.push(B[i-1])
      continue
    }
    if (B[i-1] < B[i]) {
      A.push(B[i-1])
    } else {
      A.push(B[i])
    }
  }
  const result = A.reduce((prev, current) => prev += current, 0)
  return `${result}`
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}
//  [python]
import math
from operator import itemgetter
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a,b,c = IL()
if a <= c <= b or a >= c >= b:
	print("Yes")
else:
	print("No")
//  [python]
from sys import stdin
# import math
import numpy as np
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]

A, B, C = [int(x) for x in stdin.readline().rstrip().split()]

AC = A-C
BC = B-C

abc = AC*BC
if abc>=0:
  print("No")
else:
  print("Yes")
//  [python]
import numpy as np
huga = list(map(int, input().split()))
a=huga[0]
b=huga[1]
c=huga[2]
if a>b:
  x=a
  a=b
  b=x
        
      
if a<c and b>c:
  print("Yes")
else:
  print("No")
//  [java]
import java.util.Scanner;
import java.util.stream.Stream;
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String[] b = a.split(" ");
        int[] c = Stream.of(b).mapToInt(Integer::parseInt).toArray();
        String d;
        if(c[0]<=c[1]){
            if(c[0]<=c[2]){
                if(c[1]>=c[2]){
                    d="Yes";
                }
                else{
                    d="No";
                }
            }
            else{
                d="No";
            }
        }
        else if(c[0]>=c[1]){
            if(c[0]>=c[2]){
                if(c[1]<=c[2]){
                    d="Yes";
                }
                else{
                    d="No";
                }
            }
            else{
                d="No";
            }
        }else{
            d="No";
        }
        System.out.println(d);
    }
}
//  [java]
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();
		int listI[] = splitStringToArrayOfInt(input);
		String result ="No";
		if(listI[0] > listI[2]) {
			if(listI[2] > listI[1] ) {
				result = "Yes";
			}
		}else {
			if(listI[1] > listI[2] ) {
				result = "Yes";
			}
		}
		System.out.println(result);
	}

	private static int[] splitStringToArrayOfInt(String input) {
		return Arrays.stream(input.split(" ")).filter(s -> !s.isEmpty()).mapToInt(Integer::parseInt).toArray();
	}
}
//  [java]
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        // 入力処理
        Scanner sc = new Scanner(System.in);

        int[] houses = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        int min;
        int max;
        if (houses[0] < houses[1]) {
            min = houses[0];
            max = houses[1];
        } else {
            min = houses[1];
            max = houses[0];
        }

        for (int i = min; i <= max; i++) {
            if (i == houses[2]) {
                System.out.println("Yes");
                return;
            }
        }

        System.out.println("No");
    }
}
//  [cpp]
#include <stdio.h>

int main() {
	int a, b, c;

	scanf("%d%d%d", &a, &b, &c);
	if ((a <= c && b >= c) || (a >= c && b <= c))
		printf("Yes");
	else printf("No");

	return 0;
}
//  [cpp]
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <class T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

bool isPrime(ll num) {
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    for (ll i = 3; i * i <= num; i += 2) {
        if (num % i == 0) { return false; }
    }

    return true;
};

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
bool is_integer(T x) {
    return std::floor(x) == x;
}

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int A, B, C;
    cin >> A >> B >> C;
    if (A > B) swap(A, B);
    YESNO(A < C && C < B, "Yes", "No");

    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	int n, m;
	n = min(A, B);
	m = max(A, B);

	if ((n <= C) && (m >= C)) cout << "Yes" << endl;
	else cout << "No" << endl;
}
//  [c]
#include <stdio.h>

int main(void) {
	int A, B, C;
	if (scanf("%d%d%d", &A, &B, &C) != 3) return 1;
	if (A <= C && C <= B) puts("Yes");
	else if (B <= C && C <= A) puts("Yes");
	else puts("No");
	return 0;
}
//  [c]
#include<stdio.h>

int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b){
        if(a<c && c<b){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }else if(a>b){
        if(a>c && c>b){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
}
//  [c]
#include<stdio.h>
int main(){
 int A,B,C;
 scanf("%d%d%d",&A,&B,&C);
 if((A<C&&C<B)||(B<C&&C<A)){
  printf("Yes");
 }else{
  printf("No");
 }
return 0;
}
//  [javascript]
'use strict'
function main(input) {
  input = input.trim().split(' ')
  const start = Math.min(Number(input[0]), Number(input[1]))
  const goal = Math.max(Number(input[0]), Number(input[1]))
  const result = start < Number(input[2]) && Number(input[2]) < goal
  console.log(result ? 'Yes' : 'No')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
'use strict'

function Main(input) {
    let abc = input.trim().split(' ').map((v)=>parseInt(v));

    if(abc[0]<abc[1]){
        if(abc[0]<abc[2] && abc[2] < abc[1]){
            console.log('Yes');
        } else {
            console.log('No');
        }
    } else {
        if(abc[0]>abc[2] && abc[2] > abc[1]){
            console.log('Yes');
        } else {
            console.log('No');
        }
    }

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
	input = input.split(" ");
	const a1 = parseInt(input[0]);
	const a2 = parseInt(input[1]);
	const a3 = parseInt(input[2]);

	if (a1<a2) {
		if (a1<a3 && a3<a2) {
			console.log("Yes");
		} else {
			console.log("No");
		}
	} else {
		if (a1>a3 && a3>a2) {
			console.log("Yes");
		} else {
			console.log("No");
		}
	}

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
  "fmt"
)

func main() {
  var a,b,c int
  fmt.Scanf("%v%v%v", &a, &b, &c)
  if (a<c && c<b) || (a>c && c>b) {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b, c := iScan(), iScan(), iScan()
	if a < c && c < b {
		fmt.Println("Yes")
	} else if b < c && c < a {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}
//  [ruby]
a,b,c=gets.split.map &:to_i
a,b=[a,b].sort
puts a<=c&&c<=b ? :Yes : :No
//  [ruby]
a, b, c = gets.chomp.split.map(&:to_i)
puts a < c && c < b  || b < c && c < a ? "Yes" : "No"
//  [ruby]
a,b,c = gets.split.map(&:to_i)
puts c.between?([a,b].min, [a,b].max) ? "Yes" : "No"
//  [rust]
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();
    let c: usize = iterator.next().unwrap().parse().unwrap();

    if a < c && c < b {
        return "Yes".to_string();
    }

    if b < c && c < a {
        return "Yes".to_string();
    }

    return "No".to_string();
}
//  [rust]
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        mut a: i64, mut b: i64, c: i64,
    }

    if a > b {
        std::mem::swap(&mut a, &mut b);
    }
    if a < c && c < b {
        println!("Yes");
    } else {
        println!("No");
    }
}
//  [rust]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        A: i32,
        B: i32,
        C: i32,
    }

    let ans = if (A < C && C < B) || (B < C && C < A) {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);
}
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}

/*************** テストスペース ***************/

//let input = readIntSplit(by: " ")
//let (N, M, X) = (input[0], input[1], input[2])
//let A = readIntSplit(by: " ")

/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let AB = [input[0], input[1]].sorted()
print((AB[0]...AB[1])~=input[2] ? "Yes" : "No")
//  [typescript]
namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length === 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public async getNumbers(): Promise<number[]> {
      return (await this.getLine()).split(' ').map((x) => +x);
    }

    public async getStrings(): Promise<string[]> {
      return (await this.getLine()).split(' ');
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  async function solve() {
    const sc = new Scanner();
    const [A, B, C] = await sc.getNumbers();
    if ((A <= C && C <= B) || (B <= C && C <= A)) {
      console.log('Yes');
    } else {
      console.log('No');
    }
    sc.close();
  }

  solve();
}