jiahuimbzuai/CoQuIR huggingface dataset:
//  [javascript]
main = input => {
  input = input.split('\n').map(x => x.split(' ')).map(x => x.map(parseFloat));
  var N = input[0];
  var B = input[1];
  
  B = [B[0]].concat(B).concat(B.slice(-1));
  
  var A = 0;
  
  B.reduce((N,nextToN) => {
    A += Math.min(N,nextToN);
    return nextToN;
  });
  process.stdout.write(A);
}

main(require('fs').readFileSync('/dev/stdin','utf8'));
//  [javascript]
"use strict"

function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0].trim());
  const B = input[1].trim().split(' ').map(Number);

  let cnt = N-2;
  let ret = B[0];
  for(let i=0; i<cnt; i++){
    ret += Math.min(B[i], B[i+1])
  }
  ret += B[cnt];
  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
	var data = input.split("\n")
	var n = parseInt(data[0]);
    var num = data[1].split(" ").map((n) => parseInt(n, 10));
    num.unshift(num[0])
    num.push(num[n-1])
    var sum = 0;
    
    for(var i=0; i < n; i++){
    	sum += Math.min(num[i],num[i+1]);
    }
    console.log(sum)
}
 
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict';
function main() {
  const B = input.split('\n')[1].split(' ');
  let sum = parseInt(B[0]) + parseInt(B[B.length-1]);
  for (let i = 0; i < B.length-1; ++i) {
    sum += Math.max(parseInt(B[i]), parseInt(B[i+1]));
  }
  console.log(sum);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
const main = B => {
    const max = Math.max(...B)
    var ans = 0
    for(var i = (-1*max);i<=max;i++ ) {
        for(var n = 1;n<B.length;n++) {
            const C = B.slice(0,n).concat([i],B.slice(n,B.length))
            const tmp = C.reduce((acm,current) => {return acm + current},0)
            if(C[n] == Math.min(B[n-1],B[n]) && C[n+1] == Math.min(B[n+1],B[n+2])) {
                if(ans < tmp) {
                    ans = tmp
                }
            }
        }
    }            
    if(ans == 0) {
        return B.reduce((acm,current) => {return acm + current},0) + Math.min(...B)
    }else{
        return ans - Math.max(...B)
    }
}

const input = require('fs').readFileSync('/dev/stdin','utf8').split("\n")
const N = Number(input[0])
const B = input[1].split(" ").map(x => Number(x))
console.log(main(B))
//  [javascript]
function Main(input) {
  input = input.split("\n");
  var N = input[0];
var LineB = input[1].split(" ").map(Number);
  LineB.push(Infinity)
var Sum = 0;
for(var i=0; i<N-1 ; i++){
  if(LineB[i]<LineB[i+1]){
    Sum += LineB[i];
  }else{
    Sum += LineB[i+1];
  }
}
  console.log(Sum);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func intMin(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	B := make([]int, N-1)
	for i := 0; i < N-1; i++ {
		B[i] = scanInt()
	}

	ans := B[0] + B[N-2]
	for i := 0; i < N-2; i++ {
		ans += intMin(B[i], B[i+1])
	}
	fmt.Println(ans)
}
//  [go]
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	b := make([]int, n-1)
	for i, _ := range b {
		fmt.Scan(&b[i])
	}

	ans := 0
	for i, v := range b {
		if i == 0 {
			ans += v
		}
		if i == len(b)-1 {
			ans += v
			fmt.Println(ans)
			return
		}
		if v > b[i+1] {
			ans += b[i+1]
		} else {
			ans += v
		}
	}
}
//  [go]
package main

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

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
	writer  = bufio.NewWriterSize(os.Stdout, 1000000)
)

func main() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer writer.Flush()
	n := scanInt()
	b := scanInts(n - 1)

	if n == 2 {
		fmt.Println(b[0] * 2)
		return
	}

	min := func(n ...int) int {
		ret := math.MaxInt64
		for _, v := range n {
			if v < ret {
				ret = v
			}
		}
		return ret
	}

	ans := b[0] + b[n-2]
	for i := 1; i < n-1; i++ {
		ans += min(b[i-1], b[i])
	}

	fmt.Println(ans)
}

func scanInt() int {
	i, _ := strconv.Atoi(scanString())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanString(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanString() string {
	scanner.Scan()
	return scanner.Text()
}

func scanStrings(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanString()
	}
	return s
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}

// greatest common divisor(最大公約数)
func gcd(a, b int) int {
	for {
		mod := a % b
		if mod == 0 {
			return b
		}
		a, b = b, mod
	}
}

// latest common multiple(最小公倍数)
func lcm(a, b int) int {
	return (a / gcd(a, b)) * b
}

func fact(n int) int {
	ret := 1
	for i := 1; i <= n; i++ {
		ret *= i
	}
	return ret
}

func perm(n, r int) int {
	ret := 1
	for i := 0; i < r; i++ {
		ret *= n
		n--
	}
	return ret
}

func isPrimeNum(n int) bool {

	if n <= 1 {
		return false
	}

	l := int(math.Sqrt(float64(n)) + 1.)
	for i := 2; i < l; i++ {
		if n%i == 0 {
			return false
		}
	}

	return true
}
//  [go]
package main
 
import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}
 
//func nextString() string {
//	sc.Scan()
//	return sc.Text()
//}
 
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	N := nextInt()
	n := nextInt()
	ANS := n * 2
	l := make([]int, N - 2)
	for i := 0; i < N - 2; i++ {
		l[i] = nextInt()
	}
	for i := 1; i < N - 3; i++{
		ANS = ANS + min(min(l[i-1], l[i]), l[i+1])
	}
	if N > 3 {
		ANS = ANS + min(l[N-3], l[N-4])
	}
	if N > 2 {
		ANS = ANS + l[N-3]
	}
	fmt.Println(ANS)
}

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}
//  [go]
package main
 
import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}
 
//func nextString() string {
//	sc.Scan()
//	return sc.Text()
//}
 
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	N := nextInt()
	n := nextInt()
	ANS := n * 2
	l := make([]int, N - 2)
	for i := 0; i < N - 2; i++ {
		l[i] = nextInt()
	}
	for i := 1; i < N - 3; i++{
		ANS = ANS + min(min(l[i-1], l[i]), l[i+1])
	}
	ANS = ANS + min(l[N-3], l[N-4])
	ANS = ANS + l[N-3]
	fmt.Println(ANS)
}

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}
//  [go]
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	b := make([]int, n-1)
	for i, _ := range b {
		fmt.Scan(&b[i])
	}

	ans := 0
	for i, v := range b {
		if i == 0 {
			ans += v
		}
		if i == len(b)-1 {
			ans += v
			return
		}
		if v > b[i+1] {
			ans += b[i+1]
		} else {
			ans += v
		}
	}
}
//  [ruby]
n = gets.chomp.to_i
bs = gets.chomp.split.map(&:to_i)

ret = bs[0] + bs[-1]
(1..n - 2).each do |i|
  ret += [bs[i - 1], bs[i]].min
end
puts ret
//  [ruby]
gets
b = gets.split.map(&:to_i)
if b.size == 1
    puts b[0] * 2
else
    puts b.drop(1).zip(b).map{|a, b| [a, b].min}.inject(:+) + b[0] + b[-1]
end
//  [ruby]
n = gets.to_i
b = gets.chomp.split.map(&:to_i)
ans = b[0] + b[n-2]
(0..n-3).each do |i|
  if b[i] < b[i+1]
    ans += b[i]
  else
    ans += b[i+1]
  end
end

p ans
//  [ruby]
gets.to_i
ary = gets.split.map(&:to_i)
ans = ary.size <= 1 ? ary.first : [ary[0], ary[1]].min

(0...ary.size - 1).each { |i| ans += [ary[i], ary[i + 1]].min }
puts ans + ary.last
//  [ruby]
gets.to_i
ary = gets.split.map(&:to_i)
ans = ary.size == 1 ? ary.first : [ary[0], ary[1]].min

(0...ary.size - 1).each { |i| ans += [ary[i], ary[i + 1]].min }
puts ans + ary.last
//  [ruby]
n = gets.to_i
ar = gets.chomp.split(' ')
result = []
 
for i in 0..(n-1) do
  ins = n - i - 1
  if i == (n-1)
    result.push(ar[ins].to_i)
  else
    if ar[ins].to_i > ar[ins-1].to_i
      result.push(ar[ins].to_i)
    else
      result.push(ar[ins-1].to_i)
    end
  end
end
 
result.each do |k|
  a += k
end
puts a
//  [rust]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
//#[allow(unused_imports)]
//use proconio::marker::{Isize1, Usize1, Bytes, Chars};

//#[proconio::fastout]

fn main() {
    input!{
        n: usize,
        b: [i32; n - 1],
    }
    let mut ans = b[0] + b[n - 2];
    for i in 0..(n - 2) {
        ans += min(b[i], b[i + 1]);
    }
    println!("{}", ans);
}
//  [rust]
fn input1<T: std::str::FromStr> () -> Result<T, T::Err> {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
    n.trim().parse()
}

fn input_arr<T: std::str::FromStr> () -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().flat_map(str::parse).collect()
}

fn min(a: usize, b: usize) -> usize {
    if a < b { a } else { b }
}

fn main() {
    let n: usize = input1().unwrap();
    let mut result = [100000; 100];
    for (i, b) in input_arr::<usize>().into_iter().enumerate() {
        result[i] = min(result[i], b);
        result[i + 1] = min(result[i + 1], b);
    }

    println!("{}", result.iter().take(n).sum::<usize>());
}
//  [rust]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let B: Vec<usize> = sc.vec(N-1);
    let mut ans = 0;
    ans += B[0];
    for i in 0..N-2 {
        if B[i] > B[i+1] {
            ans += B[i+1];
        } else {
            ans += B[i];
        }
    }
    ans += B[N-2];
    println!("{}", ans);
}
//  [rust]
fn main() {
    let n: usize = read_line_as_value();
    let b_in: Vec<usize> = read_line_as_vector();

    let mut cur_max = b_in[n-2];
    let mut ans = 0;
    for i in (0..n-1).rev() {
        cur_max = std::cmp::min(b_in[i], cur_max);
        ans += cur_max;
    }
    ans += cur_max;
    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]
#[allow(dead_code)]
fn main() {
    let mut hh=i::iv(3);

    let mut count=0;
    loop {
        let mut samax=0;
        let mut minnum=0;
        let mut maxnum=0;
        let mut minval=hh[0];
        let mut maxval=hh[0];
        if (hh[1]<hh[0]){
            minnum=1;
            minval=hh[1];
        }else{
            if (hh[1]>hh[0]) {
                maxnum = 1;
                maxval = hh[1];
            }
        }
        if (hh[2]<minval){
            minnum=2;
            minval=hh[2];
        }else{
            if (hh[2]>maxval){
                maxnum=2;
                maxval=hh[2];
            }
        }


        if ((maxval-minval)>=2){
            //min
            hh[minnum]=hh[minnum]+2;
        }else{
            //max
            if (maxnum==2){
                hh[0]=hh[0]+1;
                hh[1]=hh[1]+1;
            }
            if (maxnum==0){
                hh[2]=hh[2]+1;
                hh[1]=hh[1]+1;
            }
            if (maxnum==1){
                hh[0]=hh[0]+1;
                hh[2]=hh[2]+1;
            }
        }
        count=count+1;
        if (hh[0]==hh[1]&&hh[1]==hh[2]){
            break;
        }
    }
    println!("{}",count );

}


#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }
    pub fn strv(n: usize) -> Vec<String> {
        (0..n).map(|_| str()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}
//  [rust]
use std::io::*;
use std::str::FromStr;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let N: usize = read();
    let b: Vec<isize> = read_vec();
    let mut a: Vec<isize> = vec![0; N];
    let mut sum = 0;

    a[0] = b[0];
    a[1] = b[0];
    for i in 1..b.len() {
        if b[i] < b[i - 1] {
            a[i] = b[i];
            a[i + 1] = b[i];
        } else {
            a[i] = a[i - 1];
            a[i + 1] = b[i];
        }
    }

    for i in a {
        sum += i;
    }

    println!("{}", sum);
}
//  [swift]
let N = Int(readLine()!)!
let B = readLine()!.characters.split(" ").map{Int(String($0))!}
var ans = 0
var pre = B[0]
for i in B+[B.last!] {
    ans += min(pre, i)
    pre = i
}
print(ans)
//  [swift]
// 🐋💭
import Foundation

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

func readInt() -> Int {
    return Int(readLine()!)!
}

///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = index(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    let aryB = readInts()
    //_______________________ここまで入力
    
    var aryA = [Int](repeating: 0, count: n)
    aryA[0] = aryB[0]
    aryA[aryA.count - 1] = aryB[aryB.count - 1]
    for i in 2..<n {
        aryA[i-1] = min(aryB[i - 1], aryB[i - 2])
    }
    
    print(aryA.reduce(0) { $0 + $1 })
    
}

main()
//  [swift]
let n = Int(readLine()!)!

let b = readLine()!.characters.split{$0 == " "}.map{ Int(String($0))! }

var ret = b[0]

for i in 0..<n-2 {
  ret += min(b[i], b[i + 1])
}

ret += b[n - 2]

print(ret)
//  [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]
'use strict'
const main = (input: string) => {
    const std: string[] = input.trim().split('\n');
    const n: number = Number(std.shift());
    const b: number[] = std[0].split(' ').map(Number);
    let r = b[0] + b[n-2];
    for (let i = 0; i < n -2; i++) {
        r += Math.min(b[i], b[i+1]);
    }
    console.log(r);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let n=tn()-1
  let ar=tnn(n),ans=0;
  ans=ar[0]+ar[n-1]
  for(let i=1;i<n;i++){
    ans+=min(ar[i-1],ar[i])
  }
  to(ans)
}
main()
//  [typescript]
import * as fs from "fs"
const process = (n: number, b: number[]): string => {
  const res: number[] = []
  res.push(b[0])

  for (let i = 0; i < n - 2; i++) {
    if (b[i] <= b[i + 1]) {
      res.push(b[i])
    } else {
      res.push(b[i + 1])
    }
  }

  res.push(b[b.length - 1])
  return "" + res.reduce((a, b) => a + b, 0)
}

const Main = (input: string): string => {
  const aa: string[][] = input.split("\n").map((e) => e.split(" "))
  const na0: number[] = aa[0].map((e) => parseInt(e))
  const na1: number[] = aa[1].map((e) => parseInt(e))
  const [n] = na0

  const res = process(n, na1) + ""
  console.log(res)
  return res
}
Main(fs.readFileSync("/dev/stdin", "utf8"))
//  [typescript]
const lineList = require('fs').readFileSync('/dev/stdin','utf8').trim().split('\n')

const n = parseInt(lineList[0])
const b = lineList[1].split(' ').map(e => parseInt(e))
const aList = []

aList.push(b[0])
for(var i=0;i<b.length;i++) {
  aList.push(b[i])

  if(aList[i-1] > b[i]) {
    aList[i-1] = b[i]
  }
}

const answer = aList.reduce((a,e) => a + e, 0)

console.log(answer)
//  [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 = 0; i < N - 1; 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]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const input = stdin.split('\n')

const n = Number(input[0])
const b = input[1].split(' ').map(Number)

const ans = () => {
  let a = []

  b.push(Infinity)
  b.push(Infinity)

  for (let i = 0; i < n; i++) {
    if(i === 0) {
      a.push(b[0])
    } else {
      const v = Math.min(b[i - 1], b[i] ,b[i + 1])
      a.push(v)
    }
  }

  console.log(a.reduce((p, c) => p + c))
}

ans()
//  [python]
a, b, c = map(int,input().split())
if a <= c <= b or b <= c <= a:
    print('Yes')
else:
    print('No')
//  [python]
A,B,C=[int(i) for i in input().split()]
print("Yes" if (A-C)*(B-C)<0 else "No")
//  [python]
a,b,c=map(int,input().split())
if c>min(a,b) and c<max(a,b):
    print("Yes")
else:
    print("No")
//  [python]
a,b,c = map(int,input().split())
if a <= c <= b:
  print("Yes")
else:
  print("No")
//  [python]
a,b,c=map(int,input().split())
if a<c and c<b:
  print("Yes")
else:
  print("No")
//  [python]
n = int(input())
s = input()

flg = False
countw = 0
countb = 0
for l in s:
    if l=="#":
        flg = True
        countb+=1
    else:
        if flg:
            countw+=1

print(min(countw,countb))
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);
		int c = Integer.parseInt(str[2]);

		if (a > b) {
			if (c < a && c > b) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			if (c < b && c > a) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}
//  [java]
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
	static final int MAX = 2_147_483_646; // intMax 
	static final int INF = 1_000_000_000; // 10^9  
	public static void main(String[] args) throws Exception{
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int c = saori.saori_hayami();
		if((a < c && c < b) || (c < a && b < c)){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		saori.close();
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}
//  [java]
import java.util.*;


public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        String ans = "No";
        
        if(a<c && c<b){
            ans = "Yes";
        }
		
		System.out.println(ans);
	}
}
//  [java]
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int[] a = new int[3];
		for(int i = 0 ; i < 3 ; i++) a[i] = Integer.parseInt(sc.next());
		if(a[0] <= a[2] && a[2] <= a[1]) ou.print("Yes\n");
		else ou.print("No\n");
		ou.flush();
    }
}
//  [java]
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	String s = "";
      	if( a > b && a > c && c > b ){
          s = "Yes";
        }else if( b > a && b > c && c > a ){
          s = "Yes";
        }else{
          s = "No";
        }
      System.out.println(s);
	}
}
//  [cpp]
#include <cstdio>

int main()
{
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  puts((a <= c && c <= b) || (b <= c && c <= a) ? "Yes" : "No");
  return 0;
}
//  [cpp]
#include <iostream> 
#include <string>
#include <vector>

using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (b >= c && c >= a){
        cout << "Yes" << endl;
        return 0;
    }
    if (a >= c && c >= b) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main() {

  	int a,b,c;
  	cin >> a >> b >> c;
  if(a<c){
  if(b>c){
  cout << "Yes" << endl;
  }else{
   cout << "No" << endl;
  }
  }else{
  if(b<c){
  cout << "Yes" << endl;
  }else{
   cout << "No" << endl;
  }
  
  }	
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if((a <= c && c <= b) && (b <= c && c <= a))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if(a <= c && c <= b)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}
//  [cpp]
#include <bits/stdc++.h>
const long long MOD = 1e9+7;
using namespace std;
#define ll long long
#define ar array

int main () {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int a,b,c;
	cin >> a >> b >> c;

	if (a>b<c) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}
//  [c]
#include <stdio.h>

int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(c>a&&c<b||c>b&&c<a)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
//  [c]
#include <stdio.h>

int main(){
    int A,B,C,i;
    int flag=0;
    scanf("%d %d %d",&A,&B,&C);
    if(A<B){
        for(i=A;i<=B;i++){
            // i+=1;
            if(i==C) flag = 1;
            
        }
    }else if(A>B){
        for(i=A;i>=B;i--){
            if(i==C) flag = 1;
        }
    }
    if(flag == 1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}
//  [c]
#include <stdio.h>

int main(){
  int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
  if(A>B){
    A^=B;
    B^=A;
    A^=B;
  }
  if(A<C && C<B) printf("Yes\n");
  else printf("No\n");
  return 0;
}
//  [c]
#include<stdio.h>
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	puts(a<=c&&c<=b?"Yes":"No");
}
//  [c]
#include<stdio.h>
int main(void)
{
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);
	if (a < c && c < b){
		printf("YES");
	}
	else if (b < c && c < a)
	{
		printf("NO");
	}
	return 0;

}
//  [c]
#include<stdio.h>
int main(void)
{
	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]
var main = standardInput => {
  var ary = standardInput.split(" ");
  ary = ary.map((v)=>{
    return parseInt(v,10);
})
  if (ary[0] < ary[2] && ary[2] < ary[1]) {
    console.log("Yes");
  } else if (ary[0] > ary[2] && ary[2] > ary[1]) {
    console.log("Yes");
  } else {
    console.log("No");
  }
};
main(require("fs").readFileSync("/dev/stdin", "UTF-8"));
//  [javascript]
function Main (input) {
    const houses = input.split(' ');
    if((houses[2] - houses[0]) * (houses[1] - houses[2]) >= 0) {
        console.log('Yes');
    } else {
        console.log('No');
    }
}

Main(require('fs').readFileSync('/dev/stdin', 'utf-8'));
//  [javascript]
function Main(input){
  
  var str = input.trim().split(" ");
  var a = parseInt(str[0],10);
  var b = parseInt(str[1],10);
  var c = parseInt(str[2],10);
  if(a<b&&a<c&&c<b){
    console.log("Yes");}
  else if(b<a&&b<c&&c<a){
     console.log("Yes");}
  else{
 console.log("No");}

  
  
  
}//function end
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  input = input.trim()
  input = input.split(" ");
  if((input[0]>=input[2]&&input[2]>=input[1])||(input[0]<=input[2]&&input[2]<=input[1])) console.log("Yes");
  else console.log("No")
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a,b,c int
	fmt.Scan(&a,&b,&c)
	
	houses := []int{a,b}
	sort.Ints(houses)
	
	if houses[0] < c && c <houses[1] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}
//  [go]
package main

import "fmt"

func main() {
  var A, B, C int
  fmt.Scan(&A, &B, &C)
  if A < C && B > C || A > C && B < C {
    fmt.Println("Yes")
  }else {
    fmt.Println("No")
  }
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, c := nextInt(), nextInt(), nextInt()
	if (a < c && c < b) || (a > c && c > b) {
		fmt.Println("YEs")
	} else {
		fmt.Println("No")
	}
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

func getLine() string {
	if len(os.Args) < 2 {
		sc.Scan()
		return sc.Text()
	}
	return strings.Join(os.Args[1:], " ")
}

func main() {
	inp := getLine()
	sinp := strings.Split(inp, " ")

	isCrossed := "No"

	var a, b, c int
	a, _ = strconv.Atoi(sinp[0])
	b, _ = strconv.Atoi(sinp[1])
	c, _ = strconv.Atoi(sinp[2])

	if a < b && c < b || b < c && c < a {
		isCrossed = "Yes"
	}

	fmt.Println(isCrossed)
}
//  [ruby]
puts (a=gets.split.map(&:to_i)).sort[1]==a[2]?:Yes: :No
//  [ruby]
# frozen_string_literal: true

a, b, c = gets.split.map(&:to_i)

if a < c && c < b || b < c && c < a
  puts :Yes
else
  puts :No
end
//  [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.chomp.split.map(&:to_i)
puts a < c && c < b ? "Yes" : "No"
//  [ruby]
a,b,c = gets.split.map(&:to_i)

if a>b
  puts c>=b ? "Yes" : "No"
else
  puts c<=b ? "Yes" : "No"
end
//  [ruby]
a,b,c = gets.split.map(&:to_i)

if a>b
  puts c>b ? "Yes" : "No"
else
  puts c<b ? "Yes" : "No"
end
//  [rust]
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (a, b, c) = (v[0], v[1], v[2]);
    if a > c && c > b || a < c && c < b {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
    }
    if a < c && c < b || a > c && c > b {
        println!("Yes");
    } else {
        println!("No");
    }
}
//  [rust]
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

use std::mem;
use std::cmp;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let A: usize = sc.read();
    let B: usize = sc.read();
    let C: usize = sc.read();
    if A <= C && C <= B {
        println!("{}", "Yes");
    } else {
        println!("{}", "No");
    }
}
//  [rust]
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (a, b, c) = (v[0], v[1], v[2]);
    if !(a > b && b > c || a < b && b < c) {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
//  [rust]
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let a:i32 = read();
    let b:i32 = read();
    let c:i32 = read();

    println!("{}", if a < c && c < b {"Yes"} else {"No"});
    
}
//  [swift]
extension String: CollectionType {}
let num: [Int] = readLine()!.split(" ").map { Int($0)! }

var start = num[0]; var end = num[1]
if( num[0] > num[1] ){ 
  start = num[1]
  end = num[0]
}

var out = "No"
for i in start ... end {
  if( i == num[2] ) {
    out = "Yes"
    break
  }
}

print( out )
//  [swift]
import Foundation
 
// 入力
let input = readLine()!
let split = input.componentsSeparatedByString(" ")
let a = Int(split[0])! 
let b = Int(split[1])!
let c = Int(split[2])!
 
// 条件
let isOnTheWay = (a < c && c < b) || (a > c && c > b)
 
// 出力
print(isOnTheWay ? "Yes" : "No")
//  [swift]
import Foundation

// 入力
let input = readLine()!
let split = input.components(separatedBy: " ") 
let a = Int(split[0])! 
let b = Int(split[1])!
let c = Int(split[2])!

// 条件
let isOnTheWay = (a < c && c < b) || (a > c && c > b)

// 出力
print(isOnTheWay ? "Yes" : "No")
//  [typescript]
import * as fs from "fs";
const input = fs.readFileSync("/dev/stdin", "utf8").split("\n");

const nums = input[0].split(" ").map(n => Number(n));
if (nums[0] < nums[2] && nums[2] < nums[1]) {
    console.log("Yes");
} else if (nums[1] < nums[2] && nums[2] < nums[0]){
    console.log("Yes");
} else {
    console.log("No");
}
//  [typescript]
function main(input) {
  const [A,B,C] = input.split(" ").map(v => parseInt(v));
  console.log(((A < C && C < B ) || (B < C && C < A )) ? "Yes" : "No");
}
main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [typescript]
const fs = require('fs')
const stdin = fs.readFileSync('/dev/stdin', 'utf8')

const [A, B, C] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

if (A < C && C < B) {
  console.log('Yes')
} else if (A > C && B < C) {
  console.log('Yes')
} else {
  console.log('No')
}
//  [typescript]
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const [a,b,c] = input[0].split(" ").map((x: string): number => +x);

let out = 'No'
if((a < c && c < b) || (b > c && c < a)){
  out = 'Yes'
}

console.log(out);
//  [typescript]
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const [a,b,c] = input[0].split(" ").map((x: string): number => +x);

let out = 'No'
if(a < c && c < b){
  out = 'Yes'
}

console.log(out);
//  [typescript]
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const [a,b,c] = input[0].split(" ").map((x: string): number => +x);

let out = 'No'
if(b > a && b < c){
  out = 'Yes'
}

console.log(out);
//  [python]
k=int(input())
s='ACL'*k
print(s)
//  [python]
k = int(input())
#m, k = map(int, input().split())
#a = list(map(int, input().split()))

for i in range(k):
    print("ACL", end = "")
//  [python]
K=int(input())
ans=[]
for i in range(K):
    ans.extend("ACL")
print("".join(ans))
//  [python]
K = int(input())
print([ACL]*K)
//  [python]
x=3
if 1<=int(x)<=5:
  print("ACL"*int(x))
//  [python]
x=input("整数を入力してください：")
if 1<=int(x)<=5:
  print("ACL"*int(x))
//  [java]
import java.io.*;
import java.util.*;

public class Main{
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}
        public FastReader(String fileName) throws FileNotFoundException{br = new BufferedReader(new FileReader(fileName));}
        String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();}
        int nextInt(){return Integer.parseInt(next());}
        long nextLong(){return Long.parseLong(next());}
        double nextDouble(){return Double.parseDouble(next());}
        char[][] readCharArray(int n,int m) {
            String str;
            char[][] arr = new char[n][m];
            for(int i=0;i<n;i++) {
                str=nextLine();
                for(int j=0;j<n;j++) {
                    arr[i][j]=str.charAt(j);
                }
            }
            return arr;
        }
        char[][] readCharArray(int n){
            return readCharArray(n,n);
        }
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;}
    }
    static void printArray(int[] arr){
        for(int x:arr){
            System.out.print(x+" ");
        }
        System.out.println();
    }
    static final Random random=new Random();
    static void ruffleSort(int[] a) {
        int n=a.length;//shuffle, then sort
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n), temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        FastReader st = new FastReader();
        String str = "ACL";
        int n = st.nextInt();
        while(n-- > 0) {
        	System.out.print(str);
        }
        System.out.println();
    }
}