#include<stdio.h>

int main(void)
{
	int i,a[100],N,answer;
	static int min=0,max=0;
	scanf("%d",&N);
	for (i = 1; i <= N; i++)
	{
		scanf("%d", &a[i]);
	}
	for (i = 1; i <= N; i++)
	{
		if (max < a[i])
			max = a[i];
	}
	min = max;
	for (i = 1; i <= N; i++) {
		if (min > a[i])
			min = a[i];
	}
	answer = max - min;
	printf("%d", answer);
	return 0;
}


//#define ABS(X) ((X > 0) ? (X) : (-1 * X))
#define ABS(Value) ((Value < 0) ? (Value * -1) : (Value))

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int N;
	int *A;
	int max_diff;
	int current;
	int i;
	int j;

	printf("2以上100以下の整数Nを入力：");

	scanf("%d", &N);
	A = (int *)malloc(sizeof(int) + N);
	if (!A){
		printf("malloc error\n");
		return (0);
	}
	i = 0;
	while (i < N){
		printf("%d:", i + 1);
		scanf("%d", &A[i]);
		i++;
	}
	max_diff = 0;

	i = 0;
	while (i < N - 1){
		j = i + 1;
		while (j < N){
			current = A[i] - A[j];
			if (ABS(current) > max_diff){
				max_diff = ABS(current);
			}
			j++;
		}
		i++;
	}
	printf("%d\n", max_diff);
	free(A);
	return (0);
}


#include<stdio.h>
int main(){
  int n,a=1<<29,b=0,t,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){scanf("%d",&t);a=a<t?a:t;b=b<t?t:b;}
  printf("%d",b-a);
}


#include<stdio.h>
int main(){
  int n,a=1<<29,b=0,t,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){scanf("%d",&t);a=a<t?a:t;b=b<t?y:b;}
  printf("%d",b-a);
}


function Main(input) {
	input = input.split("\n");
  	var n = parseInt(input[0], 10);
  	A = input[1].split(" ");
  	var a = parseInt(A[0], 10);
  	var max = a;
  	var min = a;
  	for (var i=1; i<n; i++){
      a = parseInt(A[i], 10);
      if(a>max){
       max=a;
      }else{
       if (a<min){
         min=a;
       }
      }
    }
  console.log('%d',max-min);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


"use strict";

var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

function next() {
    return +cin[cid++];
} // number一個取得
function nextstr() {
    return cin[cid++];
} // 文字列一個取得
function nextbig() {
    return BigInt(cin[cid++]);
} // BigInteger一個取得
// 長さnの配列として取得。aは文字列フラグ
function nexts(n, a) {
    return a ? cin.slice(cid, cid += n) : cin.slice(cid, cid += n).map(a => +a);
}
// 長さnのBigInt配列として取得。
function nextsbig(n) {
    return cin.slice(cid, cid += n).map(a => BigInt(a));
}
// w個ずつを組にして長さhの配列。aは文字列フラグ。
function nextm(h, w, a) {
    var r = [],
        i = 0;
    if (a)
        for (; i < h; i++) r.push(cin.slice(cid, cid += w));
    else
        for (; i < h; i++) r.push(cin.slice(cid, cid += w).map(a => +a));
    return r;
}
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
function xArray(v) {
    var a = arguments,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + v + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
}

console.log(main().toString());

function main() {
    let n = next();
    let a = nexts(n);
    let min = a[0];
    let max = a[0];
    for (let i = 1; i < n; i++) {
        min = Math.min(min, a[i]);
        max = Math.max(max, a[i]);
    }
    return max - min;
}


var main = function main(input) {
    var N = +input.split('\n')[0]
    var A = input.split('\n')[1].split(' ')
    var min = 1000000000
    var max = 1

    for (var i = 0; i < N; i++) {
        if (+A[i] > max) max = +A[i]
        if (+A[i] < min) min = +A[i]
    }
    console.log(max - min)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))


function compareFunc(a, b) {
  return a - b;
}

function main(input) {
  let inputs = input.split(/\n/);
  let args = inputs[1].split(/\s/);
  args.sort(compareFunc);
  console.log(args[1] - args[0]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


// https://atcoder.jp/contests/abc102/tasks/abc102_b
"use strict"
function Main(input) {
  const params = input.split('\n')
  const n = Number(params[0]);
  const a = params[1].split(' ').map(Number).sort();
  console.log(a[n - 1] - a[0]);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function Main(input) {
  const args = input.split('\n');
  const n = args[0];
  const a = args[1].split(' ');
  const sort = a.sort((a, b) => a > b ? 1 : -1);
  console.log(sort[n-1] - sort[0]);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"reflect"
	"sort"
	"strconv"
	"strings"
	// "regexp"
)

/* sort */
type pair struct {
	index  int64
	p1, p2 interface{}
}
type pairs []pair

func (slice pairs) Len() int {
	return len(slice)
}

func (slice pairs) Less(i, j int) bool {
	return slice[i].index < slice[j].index
}

func (slice pairs) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}

/* sort */
type Int64Slice []int64

func (slice Int64Slice) Len() int {
	return len(slice)
}

func (slice Int64Slice) Less(i, j int) bool {
	return slice[i] < slice[j]
}

func (slice Int64Slice) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}
func Int64s(a []int64)                    { sort.Sort(Int64Slice(a)) }
func Int64sSliceAreSorted(a []int64) bool { return sort.IsSorted(Int64Slice(a)) }

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8
	INF            = 1e8
)

var (
	scanner = bufio.NewScanner(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	di      = []int64{-1, 0, 1, 0}
	dj      = []int64{0, -1, 0, 1}
)

func main() {
	buf := make([]byte, initialBufSize)
	scanner.Buffer(buf, maxBufSize)
	scanner.Split(bufio.ScanWords)
	N := readInt()
	A := make([]int64, N)
	for i := int64(0); i < N; i++ {
		A[i] = readInt()
	}
	fmt.Println(max(A...) - min(A...))
}

/*==========================================
 *             Library
 *==========================================*/
func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}
func doubleAry(h int64, w int64, init int64) (res [][]int64) {
	res = make([][]int64, h)
	for i := int64(0); i < h; i++ {
		res[i] = make([]int64, w)
		for j := int64(0); j < w; j++ {
			res[i][j] = init
		}
	}
	return
}

func aryEq(a []int64, b []int64) bool {
	return reflect.DeepEqual(a, b)
}

func clone(n []int64) (r []int64) {
	r = make([]int64, len(n))
	for i := 0; i < len(n); i++ {
		r[i] = n[i]
	}
	return
}
func write(s string) {
	writer.WriteString(s)
}

func print() {
	writer.Flush()
}

// scanner.Split(bufio.ScanWords) をコメントアウトしないと使用不可
func readLine() (s string) {
	if scanner.Scan() {
		s = scanner.Text()
	}
	return s
}

func readInt() (read int64) {
	scanner.Scan()
	read, err := strconv.ParseInt(scanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return
}

func readFloat() (read float64) {
	scanner.Scan()
	read, err := strconv.ParseFloat(scanner.Text(), 64)
	if err != nil {
		panic(err)
	}
	return
}

func readRunes() (read []rune) {
	scanner.Scan()
	for _, v := range scanner.Text() {
		read = append(read, v)
	}
	return
}

func readString() (read string) {
	scanner.Scan()
	read = scanner.Text()
	return
}

func readStrings() (read []string) {
	scanner.Scan()
	for _, v := range scanner.Text() {
		read = append(read, string(v))
	}
	return
}

func s2i(s string) int64 {
	var intVal, e = strconv.ParseInt(s, 10, 64)
	if e != nil {
		panic(e)
	}
	return intVal
}

func i2s(i int64) string {
	var strVal = strconv.FormatInt(i, 10)
	return strVal
}

func s2f(s string) float64 {
	var floatVal, e = strconv.ParseFloat(s, 64)
	if e != nil {
		panic(e)
	}
	return floatVal
}

func abs(i int64) int64 {
	return int64(math.Abs(float64(i)))
}

func max(a ...int64) int64 {
	ans := int64(0)
	for i, v := range a {
		if i == 0 {
			ans = v
		}
		if ans < v {
			ans = v
		}
	}
	return ans
}
func min(a ...int64) int64 {
	ans := int64(0)
	for i, v := range a {
		if i == 0 {
			ans = v
		}
		if ans > v {
			ans = v
		}
	}
	return ans
}

func sum(i []int64) int64 {
	sum := int64(0)
	for _, val := range i {
		sum += val
	}
	return sum
}

func split(s string) []string {
	return strings.Fields(s)
}

func strAry2intAry(strs []string) []int64 {
	var ret = make([]int64, 0, len(strs))
	for _, str := range strs {
		var intVal = s2i(str)
		ret = append(ret, intVal)
	}
	return ret
}

func intAry2strAry(nums []int64) []string {
	var ret = make([]string, 0, len(nums))
	for _, num := range nums {
		var strVal = i2s(num)
		ret = append(ret, strVal)
	}
	return ret
}

func ary2str(strs []string) string {
	return strings.Join(strs, " ")
}

func reverse(res []int64) []int64 {
	for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {
		res[i], res[j] = res[j], res[i]
	}
	return res
}
func reverseStr(res []string) []string {
	for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {
		res[i], res[j] = res[j], res[i]
	}
	return res
}

func ini(res []int, init int) {
	if len(res) == 0 {
		return
	}
	res[0] = init
	for i := 0; i < len(res); i++ {
		copy(res[i:], res[:i])
	}
}

//
// func regexpExample() {
//     // Your code here!
//     var str = "13:20"
//     r := regexp.MustCompile(`(\d+):(\d+)`)
//     fmt.Println(r.FindStringSubmatch(str))
// }

// type Country struct {
//     gold int
//     silver int
//     blonze int
// }

// // 複数ソートのサンプル
// func stableSortExample() []Country{
//     var country = []Country {
//         {gold:1, silver:2, blonze:3},
//         {gold:1, silver:2, blonze:3},
//         {gold:1, silver:3, blonze:2},
//         {gold:1, silver:3, blonze:3},
//     }
//     sort.SliceStable(country, func(i, j int) bool { return country[i].blonze > country[j].blonze })
//     sort.SliceStable(country, func(i, j int) bool { return country[i].silver > country[j].silver })
//     sort.SliceStable(country, func(i, j int) bool { return country[i].gold > country[j].gold })
//     return country
// }


package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
  var N int
  var A []int

  sc.Split(bufio.ScanWords)

  // n枚を変数にする
  fmt.Scanf("%d", &N)
  // カードをarrayに落とし込む
  for i := 1; i <= N; i++ {
    A = append(A, newLine())
  }

  // sort
  //sort.Ints(a)
  sort.Sort(sort.Reverse(sort.IntSlice(A)))

  fmt.Println(A[0] - A[N-1])
}


package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func main() {
	N := getInt()
	A := getIntArray(N)

	maxDiff := 0
	for i := 0; i < N-1; i++ {
		for j := i+1; j < N; j++ {
			if maxDiff < abs(A[i] - A[j]) {
				maxDiff = abs(A[i] - A[j])
			}
		}
	}
	fmt.Println(maxDiff)
}

type Graph struct {
	n     int
	edges [][]int
}

func NewGraph(n int) *Graph {
	g := &Graph{
		n:     n,
		edges: make([][]int, n),
	}
	return g
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(c int, edges [][]int, visited map[int]struct{}) {
	visited[c] = struct{}{}

	for _, v := range edges[c] {
		_, flag := visited[v]
		if flag {
			continue
		}
		dfs(v, edges, visited)
	}
}

func bfs(c int, graph *Graph) {
	next := make([]int, 0)
	next = append(next, c)
	visited := make(map[int]struct{})

	for ; len(next) != 0; {
		u := next[0]
		next = next[1:]
		visited[u] = struct{}{}

		for _, v := range graph.edges[u] {
			_, flag := visited[v]
			if flag {
				continue
			}

			// なにか処理

			next = append(next, v)
		}
	}
}

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

func getIntArray(n int) []int {
	array := make([]int, n)
	for i := 0; i < n; i++ {
		array[i] = getInt()
	}
	return array
}

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

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 0 {
		t := powMod(n, p/2)
		return calcMod(t * t)
	} else {
		return calcMod(n * powMod(n, p-1))
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray)-1])
}

func calcMod(x int) int {
	return x % mod
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func isPrime(n int) bool {
	if n < 2 {
		return false
	} else if n == 2 {
		return true
	} else if n % 2 == 0 {
		return false
	}

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

	return true
}

func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

func makeRange(min, max int) []int {
	a := make([]int, max-min+1)
	for i := range a {
		a[i] = min + i
	}
	return a
}

func powerset2(nums []int) [][]int {
	length := int(math.Pow(2, float64(len(nums))))
	result := make([][]int, length)

	index := 0
	result[index] = []int{}
	index++

	for _, n := range nums {
		max := index
		for i := 0; i < max; i++ {
			result[index] = copyAndAppend(result[i], n)
			index++
		}
	}

	return result
}

func copyAndAppend(nums []int, n int) []int {
	dst := make([]int, len(nums)+1)
	copy(dst, nums)
	dst[len(nums)] = n
	return dst
}

func calcGcd(x, y int) int {
	if y == 0 {
		return x
	} else if x >= y {
		return calcGcd(y, x % y)
	} else {
		return calcGcd(x, y % x)
	}
}

func getDivisor(n int) []int {
	var divisor []int
	divisor = append(divisor, 1)
	if n != 1 {
		divisor = append(divisor, n)
	}

	sqrt := int(math.Sqrt(float64(n)))
	for i := 2; i <= sqrt; i++ {
		if n % i == 0 {
			divisor = append(divisor, i)
			divisor = append(divisor, n/i)
		}
	}
	return divisor
}

type intHeap []int

func (h intHeap) Len() int {
	return len(h)
}

func (h intHeap) Less(i, j int) bool {
	return h[i] > h[j]
}

func (h intHeap) Swap(i, j int) {
	h[i], h[j] = h[j], h[i]
}

func (h *intHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *intHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func initHeap() *intHeap {
	ih := &intHeap{}
	heap.Init(ih)
	return ih
}

func (h *intHeap) pushHeap(n int) {
	heap.Push(h, n)
}

func (h *intHeap) popHeap() int {
	return heap.Pop(h).(int)
}

func factMod(n int) int {
	value := 1
	for ; n > 1; n-- {
		value = calcMod(value * n)
	}
	return value
}

func combinationMod(n, k int) int {
	factN := factMod(n)
	factK := factMod(k)
	factNK := factMod(n - k)
	factKR := powMod(factK, mod - 2)
	factNKR := powMod(factNK, mod - 2)
	return calcMod(factN * calcMod(factKR * factNKR))
}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	fmt.Print(a[0] - a[1])
}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	fmt.Println(a[0] - a[1])
}


package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	arry := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arry[i])
	}
	min := 1000000000
	max := 0
	for i := 0; i < n; i++ {
		// MIN
		if arry[i] < min {
			min = arry[i]
		} else if arry[i] > max {
			max = arry[i]
		}
	}

	fmt.Println(max - min)

}


_n = gets.strip.to_i
nums = gets.strip.split.map(&:to_i)
puts nums.max - nums.min


n = gets.to_i
a = gets.split.map(&:to_i).sort
puts a[-1] - a[0]


N = gets.to_i
A = gets.split(' ').map(&:to_i)

p A.max - A.min


n = gets.to_i
num = gets.strip.split.map(&:to_i)
pust num.max-num.min


n = gets.chomp.to_i
ary = gets.split(" ").map(&:to_i).sort

puts (ary[-1] - ary[-1]).abs


n = gets.chomp.to_i
a = gets.chomp.split("").map(&:to_i)

puts a.max - a.min


#[allow(unused_macros, dead_code)]
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)*}
    };
}

#[allow(unused_macros, dead_code)]
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)*}
    };
}

#[allow(unused_macros, dead_code)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[allow(dead_code)]
struct UnionFind {
    parent: Vec<usize>,
    rank: Vec<usize>,
    size: Vec<usize>,
}

#[allow(dead_code)]
impl UnionFind {
    fn new(n: usize) -> UnionFind {
        let mut p = vec![0; n];
        for i in 0..n {
            p[i] = i;
        }
        return UnionFind {
            parent: p,
            rank: vec![0; n],
            size: vec![1; n],
        };
    }

    fn find(&mut self, x: usize) -> usize {
        if x == self.parent[x] {
            x
        } else {
            let p = self.parent[x];
            let pr = self.find(p);
            self.parent[x] = pr;
            pr
        }
    }

    fn same(&mut self, a: usize, b: usize) -> bool {
        self.find(a) == self.find(b)
    }

    fn unite(&mut self, a: usize, b: usize) {
        let a_root = self.find(a);
        let b_root = self.find(b);
        if a_root == b_root {
            return;
        }
        if self.rank[a_root] > self.rank[b_root] {
            self.parent[b_root] = a_root;
            self.size[a_root] += self.size[b_root];
        } else {
            self.parent[a_root] = b_root;
            self.size[b_root] += self.size[a_root];
            if self.rank[a_root] == self.rank[b_root] {
                self.rank[b_root] += 1;
            }
        }
    }

    fn get_size(&mut self, x: usize) -> usize {
        let root = self.find(x);
        self.size[root]
    }
}

const MOD_P: usize = 1000000007;

#[allow(dead_code)]
// fact(n) = n! mod p
fn fact(n: usize) -> usize {
    let mut acc = 1;
    for i in 1..n + 1 {
        acc = acc * i % MOD_P;
    }
    acc
}

#[allow(dead_code)]
fn mod_pow(b: usize, mut e: usize) -> usize {
    let mut base = b;
    let mut acc = 1;

    while e > 1 {
        if e % 2 == 1 {
            acc = acc * base % MOD_P;
        }
        e /= 2;
        base = base * base % MOD_P;
    }

    if e == 1 {
        acc = acc * base % MOD_P;
    }

    acc
}

#[allow(dead_code)]
fn comb(n: usize, r: usize) -> usize {
    // nCr = n! / (r! (n-r)!) = n! (r!)^(p-2) ((n-r)!)^(p-2)
    let x = ((n - r + 1)..(n + 1)).fold(1, |p, x| p * x % MOD_P);
    let y = mod_pow(fact(r), MOD_P - 2);
    x * y % MOD_P
}

#[allow(dead_code)]
fn gcd(a: usize, b: usize) -> usize {
    if b > a {
        gcd(b, a)
    } else if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}

#[allow(dead_code)]
fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

use std::cmp::{max, min};

fn main() {
    input! {
        n: usize,
        mut a: [usize;n],
    }
    a.sort();
    let ans = a[n - 1] - a[0];
    println!("{}", ans);
}


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")
    };
}

fn main() {
    input! {
        n: usize,
        aa: [u32;n]
    }
    println!("{}",
        aa.iter().max().unwrap() - aa.iter().min().unwrap());
}


use std::io;
use std::cmp::{max, min};

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let v:Vec<u64> = procon_read();
	let mut mini:u64 = v[0];
	let mut maxi:u64 = v[0];
	for i in 0..n {
		mini = min(v[i as usize], mini);
		maxi = max(v[i as usize], maxi);
	}
	println!("{}", maxi - mini);
}


use std::process;
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)*}
    };
}

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!{
        n: i64,
        v: [i64; n],
    }
    let mut ans : Vec<i64> = Vec::new();

    if v.len() ==  2 {
        println!("{}", (v[0] - v[1]).abs());
        process::exit(0);
    }

    for i in 0..v.len() {
        for j in (i+1)..(v.len()-1) {
            ans.push(v[i]-v[j]);
    }
    }

    for i in &v {
    }
    ans.sort();

    println!("{}" , if ans.first().unwrap().abs() > ans.last().unwrap().abs() { ans.first().unwrap().abs()}else {ans.last().unwrap().abs()});

}


use std::process;
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)*}
    };
}

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")
    };
}
#[macro_use] extern crate itertools;
use itertools::Itertools;
use std::cmp;
fn main() {
    input!{
        n: i64,
        v: [i64; n],
    }
    let mut ans:Vec<i64> = Vec::new();
    for i in v.iter().combinations(2) {
        ans.push(i[0]-i[1]);
    }

    println!("{}", cmp::max(ans.iter().max().unwrap().abs(),ans.iter().min().unwrap().abs()));

}


use io::*;
use std::*;

fn solve(_n: i64, a: Vec<i64>) {
    let max = a.iter().cloned().fold(i64::MIN, cmp::max);
    let min = a.iter().cloned().fold(i64::MAX, cmp::min);
    println!("{}", max - min);
}

fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let n: i64;
    n = scanner.next();
    let mut a: Vec<i64> = vec![0i64; (n) as usize];
    for i in 0..(n) as usize {
        a[i] = scanner.next();
    }
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(n, a)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

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

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_end().to_owned()
    }
}


import Foundation
let a = Int(readLine()!)!
let b = readLine()!.split(separator: " ").map({Int($0)!}).sorted()
print(b[a-1] - b[0])


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: 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 _ = readLine()!
let arr = readIntSplit(by: " ")
print(arr.max()-arr.min())


import Foundation

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

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

func readTwoInts() -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: " ").map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

let N = readInt()

var A = readInts()
A = A.sorted()
print(A[A.count-1]-A[0])


import Foundation
let a = Int(readLine()!)!
let b = readLine()!.split(separator: " ").map({Int($0)!}).sorted()
print(b[0] - b[a-1])


import Foundation
let a = Int(readLine()!)!
let b = readLine()!.split(separator: " ").map({Int($0)!}).sorted()
print(b[0] - b[a])


import Foundation
_ = readLine()
let ai = readInts().sorted()
print(abs(ai.last!-ai.first!))


import * as fs from 'fs';

namespace AtCoder.abc102 {
    class ProgramB {
        args: string[];

        constructor(args: string[]) {
            this.args = args;
        }

        main(): void {
            const a: number[] = this.args[1].split(' ').map(Number);
            const sorted: number[] = a.sort((a: number, b: number) => a - b);

            console.log(Math.abs(sorted[sorted.length - 1] - sorted[0]));

        }
    }

    new ProgramB(fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n')).main();
}


const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const n = stdin.split('\n')[0]
const a = stdin
  .trim()
  .split('\n')[1]
  .split(' ')
  .map(Number)

const ans = _ => {
  const min = Math.min(...a)
  const max = Math.max(...a)

  return Math.abs(max - min)
}

console.log(ans())


const log = console.log;

const parseLines = (s: string) => s.trim().split("\n");

const parseSpaceSeparated = (line: string) => line.trim().split(" ");

const parseDecimalInt = (s: string) => parseInt(s);

const parseSpaceSeparatedDecimalInt = (line: string) =>
  parseSpaceSeparated(line).map(parseDecimalInt);

// ----

function Main(input: string): void {
  const [head, body] = parseLines(input);
  const a = parseSpaceSeparatedDecimalInt(body);

  log(Math.max(...a) - Math.min(...a));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


package main

import (
	"fmt"
	"math"
	"sort"
)

//4
//1 4 6 3
func main() {
	var n int
	fmt.Scanf("%d", &n)

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		var a int
		fmt.Scanf("%d", &a)
		arr[i] = a
	}

	sort.IntSlice(arr).Sort()
	var ans int
	ans = int(math.Abs(float64(arr[len(arr)-1]-arr[0])))
	fmt.Println(ans)
}


const Main = (input) => {
  // 1行目がinpt[0], 2行目がinpt[1], …に入る
  const inpt = input.split('\n');
  // 1つめがinpt[0], 2つめがinpt[1], …に入る
  // const inpt = input.split(' ');
  const ar = inpt[1].split(' ');
  let mx = 1, mn = 10 ** 9;
  for (let v of ar) {
    mx = mx > v ? mx : v;
    mn = mn < v ? mn : v;
  }
  console.log(Math.abs(mx - mn));
}

// 標準入力を受け取るおまじない
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


# -*- coding: utf-8 -*-
"""
Created on Thu Dec 19 22:37:09 2019

@author: lucifer
"""
n=int(input())
if n%500==0:
  print(1000*int(n/500))
else:
  s=int(n/500)
  x=1000*s+int((n-(s*500))/5)*5
  print(x)


X= int(input())

div500= int(X/500)
div5= int((X%500)/5)
happy= div500*1000 + div5* 5

print(happy)


x=int(input())
a=x//500
b=x%500
c=b//5
print(a*1000+c*5)


x = int(input())
a = (x/500)*1000
x -= 500*(x/500)
b = 5*(x/5)
print(a+b)


X = int(input())

a, mod = divmod(X, 500)
b = mod % 5

print(a * 1000 + b * 5)


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int N = Integer.parseInt(st.nextToken());
		int x = N / 500;
		int sum = x * 1000;
		N %= 500;
		sum += (N / 5) * 5;
		System.out.println(sum);
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

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

		int cash=Integer.parseInt(in.readLine());

		long total=(cash/500)*1000;

		cash%=500;

		total+=(cash/5)*5;

		System.out.println(total);

	}

}


import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		long X = nl();
		long tot = X / 500 * 1000L;
		X -= X / 500 * 500;
		tot += X / 5 * 5L;
		out.println(tot);
	}

	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}


import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int i,j;
		int max=0;
		int k=x/500;
		int l=x/5;

		for(i=0;i<=k;++i) {
			for(j=0;j<=l/2;++j) {
				if(x-500*i-5*j>=0 && max<(1000*i)+(5*j)){
					max=1000*i+5*j;
				}
			}
		}
		System.out.println(max);
	}

}


import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int i,j;
		int max=0;
		int k=x/500;
		int l=x/5;

		for(i=0;i<=k;++i) {
			for(j=0;j<=l;++j) {
				if(x-500*i-5*j>=0 && max<(1000*i)+(5*j)){
					max=1000*i+5*j;
				}
			}
		}
		System.out.println(max);
	}

}


import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long X = sc.nextLong();
    long happy = 0;
    long cnt1 = 0;
    long cnt2 = 0;
    long rem1 = 0;
    long rem2 = 0;
    long rem3 = 0;

    for(int i=1; i<1000; i++) {
      rem1 = X - 500*i;
      if(rem1 > 0) {
        cnt1++;
      } else {
        break;
      }
    }

    rem2 = X - 500*2;

    for(int i=1; i<1000; i++) {
      rem3 = rem2 - 5*i;
      if(rem3 > 0) {
        cnt2++;
      } else {
        break;
      }
    }

    happy = 1000*cnt1 + 5*cnt2;
    System.out.println(happy);

  }
}


#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF (1LL << 40)
int main() {
	int n, k, m, l;
	scanf("%d", &n);
	k = n / 500;
	m = n - k * 500;
	l = m / 5;
	printf("%d\n", k * 1000 + l * 5);
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include<map>
using namespace std;

int main() {
    int X;
    cin >> X;

    int result500;
    int result5;

    result500 = X / 500;
    X = X - result500 * 500;
    result5 = X / 5;
    int happy = result500 * 1000 + result5 * 5;
    cout << happy << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    cin>>n;
    int ans=(n/500)*1000;
    n%=500;
    ans+=(n/5)*5;
    cout<<ans;
}


#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	int x; cin >> x;
	int cnt_500 = x / 500;
	int cnt_5 = (x - x / 500 * 500) / 5;
	ll ans = 1000 * cnt_500 + 5 * cnt_5;
	return 0;
}


#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

/*--------switch header--------*/
#define ALGORITHM   1
#define CASSERT     0
#define CMATH       0
#define DEQUE       0
#define FUNCTIONAL  1
#define IOMANIP     1
#define IOSTREAM    1
#define LIST        0
#define MAP         0
#define QUEUE       0
#define SET         0
#define STRING      1
#define UTILITY     1
#define VECTOR      1
#define VEC_DEBUG   1

using namespace std;

#pragma region headers
#if VEC_DEBUG
#define _GLIBCXX_DEBUG
#endif
#if ALGORITHM
#include <algorithm>
#endif
#if CASSERT
#include <cassert>
#endif
#if CMATH
#include <cmath>
#endif
#if DEQUE
#include <deque>
#endif
#if FUNCTIONAL
#include <functional>
#endif
#if IOMANIP
#include <iomanip>
#endif
#if IOSTREAM
#include <iostream>
#endif
#if LIST
#include <list>
#endif
#if MAP
#include <map>
#endif
#if QUEUE
#include <queue>
#endif
#if SET
#include <set>
#endif
#if STRING
#include <string>
#endif
#if UTILITY
#include <utility>
#endif
#if VECTOR
#include <vector>
#endif
#pragma endregion

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define ALL(x)          (x).begin(), (x).end()
#define rALL(x)         (x).rbegin(), (x).rend()
#define REP(i, n)       for(int i = 0; (i) < (n); (i)++)
#define rREP(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define FOR(i, a, b)    for(int i = (a); (i) < (b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/

/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int x; cin >> x;
    int a = x/500;
    int b = x%1000 / 5;

    cout << a * 1000 + b * 5 << endl;

return 0;
}


#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
using ll = long long;

int main()
{
	int n;
	cin >> n;
	ll ans = 0;
	ans += n/1000*2000;
	n -= ans/2;
	ans += n/5*5;
	cout<<ans<<endl;
}


#include <stdio.h>

int main(){
  int x, ans1, ans2;
  scanf("%d",&x);
  ans1=x/500;
  ans1*=1000;
  ans2=x%500;
  ans2/=5;
  ans2*=5;
  printf("%d",ans1+ans2);
}


#include<stdio.h>

int main(){
  int i;
  int s = 0;
  scanf("%d", &i);

  s += (i/500)*1000;
  i -= (i/500)*500;
  s += (i/5)*5;
  i -= (i/5)*5;
  printf("%d", s);

  return 0;
}


#include<stdio.h>
int main(void){
  int a,b,c,d,x;
  scanf("%d",&a);
  b=a/500;
  b=b*1000;
  c=a%500;
  d=c/5;
  d=d*5;
  x=b+d;
  printf("%d\n",x);
    return 0;
}


#include<stdio.h>

int main(void){
  long long x,c=0;
  scanf("%lld",&x);
  while(x>500){
    c+=1000;
    x-=500;
  }
  while(x>5){
    c+=5;
    x-=5;
  }
  printf("%lld",c);
  return 0;
}


#include<stdio.h>

int main(void){
  int n,c=0,h=0;
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    c++;
    if(c==500){
      h+=1000;
      c-=500;
    }else if((n-i)<500 && c==5){
      h+=5;
      c-=5;
    }
  }
  printf("%d\n",h);
  return 0;
}


#include<stdio.h>

int main(void){
  int n,c=0,h=0;
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    c++;
    if(c==500){
      h+=1000;
      c-=500
    }else if((n-i)<500) && c==5){
      h+=5;
      c-=5;
    }
  }
  printf("%d\n",h);
  return 0;
}


function Main(input) {
    input = input.split("\n");
  	var a = input[0]-0;
  	var aa = ~~(a/500);
  	var ans = 0;
  	ans += aa*1000;
  	var bb = ~~((a-aa*500)/5);
  	ans += bb*5;
  	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function Main(input) {
    // const input = Number(input)
    const _500 = Math.floor(input / 500)
    const remain = input - (500 * _500)
    // if (_500 >= 1) {
        const _5 = Math.floor((remain) / 5)
        console.log(1000 * _500 + 5 * _5)
    // } else {
    //     console.log(1000 * _500)
    // }
}
// Main(12345613265)
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function Main(input){
	var X = parseInt(input,10);
  	var d = Math.floor(X/5);
  	var fhc = Math.floor(d/100);
  	var fc = d%100;
  	var res = (fhc * 1000) + (fc * 5);
	console.log(res);
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));


function Main(n) {
    if (n > 499) {
        let _n = Math.floor(n / 500);
        let _n2 = n % 500;
        let _n3 = Math.floor(_n2 % 5);
        console.log((_n * 1000) + (_n3 * 5));
    } else {
        console.log(Math.floor(n / 5) * 5);
    }
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function Main(n) {
    if (n > 499) {
        let _n = Math.floor(n / 500);
        let _n2 = n % 500;
        let _n3 = Math.floor(_n2 % 5);
        console.log((_n * 1000) + (_n3 * 5));
    } else {
        console.log((Math.floor(n / 5) * 5));
    }
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function Main(n) {
    if (n > 499) {
        let _n = Math.floor(n / 500);
        let _n2 = n % 500;
        let _n3 = Math.floor(_n2 % 5);
        console.log((_n * 1000) + (_n3 * 5));
    } else {
        console.log((Math.floor(n / 5) * 5));
    }
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


package main

import "fmt"

func main() {
	var money int
	fmt.Scan(&money)

	var coin500Num int = money / 500
	var rem int = money % 500
	var coin5Num int = rem / 5

	fmt.Println(coin500Num*1000 + coin5Num*5)
}


package main

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

func main() {
	nextReader = newScanner()
	x := nextInt()
	fmt.Println((x / 500 * 1000) + (x % 500 / 5 * 5))
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

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


package main

import "fmt"

func main() {
  var X int
  fmt.Scan(&X)

  ans := (X/500)*1000 + (X-500*(X/500))/5*5
  fmt.Println(ans)

}


package main

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

func main() {
	sc := newScanner()
	var x = sc.readInt64()
	var ans int64
	ans += (x / 500) * 1000
	var r = x % 500
	ans += r * 5
	fmt.Println(ans)

}

//////////////////
//////////////////
//////////////////

func abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func reverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func reverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type scanner struct {
	bufScanner *bufio.Scanner
}

func newScanner() *scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &scanner{bufSc}
}

func (sc *scanner) readString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *scanner) readInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *scanner) readInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


package main

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

func main() {
	sc := newScanner()
	var x = sc.readInt()
	var ans int
	ans += (x / 500) * 1000
	var r = x % 500
	ans += r * 5
	fmt.Println(ans)

}

//////////////////
//////////////////
//////////////////

func abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func reverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func reverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type scanner struct {
	bufScanner *bufio.Scanner
}

func newScanner() *scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &scanner{bufSc}
}

func (sc *scanner) readString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *scanner) readInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *scanner) readInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


package main

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

var sc = bufio.NewScanner(os.Stdin)

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

	x := nextInt()
	acount := x / 500
	bcount := x % 500 / 5
	println(acount*1000 + bcount*5)

}

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


X = gets.to_i

puts X/500*1000 + X%500/5*5


num = gets.chomp.to_i
uresisa = 0

uresisa += (num/500) * 1000
num = num%500
uresisa += (num/5) * 5
num = num%5

puts uresisa


s = gets.to_i

count_500 = s / 500
rest_500 = s % 500
count_5 = rest_500 / 5

happy = (count_500 * 1000) + (count_5 * 5)

puts happy


x = gets.to_i

score = 0
score += x/500 * 1000
x = x/500
score += x/5 * 5

puts score


x,y=gets.split.map!(&:to_f)
s=gets.split.map!(&:to_i)
s=s.sort.reverse
max=s.sum
if s[y-1]>=(max/(4*y)).to_f
  puts "Yes"
else
  puts "No"
end


num = gets.chomp.to_i
uresisa = 0

uresisa += num/500
num = num%500
uresisa += num/5
num = num%5

puts uresisa


use proconio::{fastout, input};

#[fastout]
fn main() {
    let mut x: usize;
    input! {x: usize};

    let five_handred_count = x / 500;
    let five_count = (x - five_handred_count * 500) / 5;

    println!("{}", five_handred_count * 1000 + five_count * 5);
}


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 main() {
    let x:u32 = read();
    let n1 = x / 500;
    let n2 = (x - n1 * 500) / 5;
    println!("{}", n1*1000+n2*5);
}


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

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")
}

fn main() {
    let in_x: i32 = read();
    let a = in_x / 500;
    let b = (in_x % 500) / 5;

    println!("{}", a * 1000 + b * 5);
}


fn main() {
    let x = read::<usize>();
    let x500 = x / 500;
    let x5 = x % 500;
    println!("{}", x500 * 1000 + x5 * 5);
}

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


use std::io::Read;

fn main() {
    let i = input();
    println!("{}", solve(i));
}

fn input() -> usize {
    let mut buf = String::from("");
    std::io::stdin().read_line(&mut buf).unwrap();
    println!("buf = {}", buf);
    buf.pop();
    let i: usize = buf.parse().unwrap();
    i
}

fn solve(input: usize) -> usize {
    if input == 0 {
        return 0;
    }

    let number_500 = input / 500;
    let remain = input - (number_500 * 500);
    let number_5 = remain / 5;

    number_500 * 1000 + number_5 * 5
}


use std::io::Read;

fn main() {
    let i = input();
    println!("{}", solve(i));
}

fn input() -> usize {
    let mut buf = String::from("");
    std::io::stdin().read_line(&mut buf).unwrap();
    println!("buf = {}", buf);
    buf.retain(|c| c != '\n');
    let i: usize = buf.parse().unwrap();
    i
}

fn solve(input: usize) -> usize {
    if input == 0 {
        return 0;
    }

    let number_500 = input / 500;
    let remain = input - (number_500 * 500);
    let number_5 = remain / 5;

    number_500 * 1000 + number_5 * 5
}


import Foundation
var X = Int(readLine()!) ?? 0
var moneyArray = [0,0]

moneyArray[0] = (X/500)*1000
X = X%500
moneyArray[1] = (X/5)*5
X = X%5

let happiness =  moneyArray.reduce(0){(num1: Int, num2: Int)  -> Int in
  return num1 + num2
}
print(happiness)


import Foundation

var x = Int(readLine()!) ?? 0
var money = [0,0]

money[0] = (x / 500) * 1000
x = x % 500
money[1] = (x / 5) * 5
x = x % 5

let happinessScore =  money.reduce(0) { (num1: Int, num2: Int) -> Int in
  return num1 + num2
}

print(happinessScore)


import Foundation

var num:Int = Int(readLine()!)!
var joy = 0
while (num >= 500){
  num -= 500
  joy += 1000
}
while (num >= 5){
  num -= 5
  joy += 5
}
print(joy)


import Foundation

var x = Int(readLine()!) ?? 0
var money = [0,0]

money[0] = (x / 500) * 1000
x = x % 500
money[1] = (x / 5) * 5
x = x % 5

let happinessScore =  moneyArray.reduce(0) { (num1: Int, num2: Int) -> Int in
  return num1 + num2
}

print(happinessScore)


#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  ll x;
  cin >> x;
  ll ans = 0;
  ans += x / 500 * 1000;
  x %= 500;
  ans += x / 5 * 5;
  print(ans);
  return 0;
}


function main(input) {
    const lines = input.split("\n");
    const X = lines[0];

    const coin500 = Math.floor(X / 500);
    const mod = X % 500;
    const coin5 = Math.floor(mod / 5);
    const res = coin500 * 1000 + coin5 * 5;

    console.log(res);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


// inputに入力データ全体が入る
function Main(input) {

  let val = parseInt(input);
  let ans = Math.floor(val / 500) * 1000;
  val %= 500;
  console.log(ans + Math.floor(val / 5) * 5)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


const main = (input: string) => {
  const hasMoney = Number(input);

  let happyValue = Math.floor(hasMoney / 500) * 1000;
  const modMoney = hasMoney % 500;

  happyValue += Math.floor(modMoney / 5) * 5;

  console.log(happyValue);
}

// *この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
main(require("fs").readFileSync("/dev/stdin", "utf8"));


"use strict";

// B - Golden Coins
// https://atcoder.jp/contests/abc160/tasks/abc160_b

function Main(input) {
    const X = parseInt(input, 10);

    const count500 = X / 500;
    const modX = X % 500;
    const count5 = modX / 5;

    //出力
    console.log(count500 * 1000 + count5 * 5);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


class NormalInput {
  input: string[];
  pointer: number;
  constructor(raw: string) {
    this.input = raw.split(/ |\n/);
    this.pointer = 0;
  }
  int = (): number => {
    const ret = parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  };
  str = (): string => {
    const ret = this.input[this.pointer];
    this.pointer++;
    return ret;
  };
  strs = (length: number): string[] => {
    let ret: string[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.str());
    }
    return ret;
  };
  ints = (length: number): number[] => {
    let ret: number[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.int());
    }
    return ret;
  };
}

function Main({ int, str, strs, ints }: NormalInput) {
  const X=int();
  console.log(Math.floor(X/5))
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8")));


a,b,c = list(map(int, input().split()))
print("Yes" if a+b>=c else "No")


a, b, c = map(int, input().split())
if a + b >= c:
    print('Yes')
else:
    print('No')


#!/usr/bin/env python3
import sys
INF = float("inf")

def yes():
    print("Yes")  # type: str

def no():
    print("No")  # type: str

def solve(A: int, B: int, C: int):
    if A+B >= C:
        yes()
    else:
        no()
    return

def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


a,s,d=map(int, input().split())
print('Yes' if a+b>=c else 'No')


A, B, C = map(int, input().split())
print('Yes' if A+B*2 >= C else 'No')


A, B, C = map(int, input())
print('Yes' if A+B*2 >= C else 'No')


import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		if(A+B>=C)
			System.out.println("Yes");
		else
			System.out.println("No");

	}

	//以下、自作ライブラリ

	/*
		int N = sc.nextInt();

		int[] a = new int[N];
		for (int i = 0; i < N; i++)
			a[i] = sc.nextInt();

		String s = sc.next();

		String[] a = new String[N];
		for (int i = 0; i < N; i++)
			a[i] = sc.next();

		int[][] a = new int[N][2];
		for (int i = 0; i < N; i++) {
			a[i][0] = sc.nextInt();
			a[i][1] = sc.nextInt();
		}
		Arrays.sort(a, (x, y) -> Integer.compare(x[0], y[0]));
	 */

	//階乗
	public static int fact(int n) {
		if (n == 1 || n == 0)
			return 1;
		else
			return n * fact(n - 1);
	}

	//指定した値以上の要素が最初に現れる位置
	//要素の数は+1（配列のズレ)
	public static long lowerBound(int n, long[] x, long y) {
		int left = 0;
		int right = n;
		while (left < right) {
			int mid = (left + right) / 2;
			if (x[mid] < y) {
				left = mid + 1;
			} else {
				right = mid;
			}
		}
		return left;
	}

	//指定した値より大きい要素が最初に現れる位置
	//要素の数は+1（配列のズレ)
	public static long upperBound(int n, long[] x, long y) {
		int left = 0;
		int right = n;
		while (left < right) {
			int mid = (left + right) / 2;
			if (x[mid] <= y) {
				left = mid + 1;
			} else {
				right = mid;
			}
		}
		return left;
	}

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


import java.awt.List;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main
{
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int A=ni(), B=ni(), C=ni();
		out.println(A+B>=C?"Yes":"No");

	}

	void run() throws Exception
	{
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{ new Main().run(); }

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf)
		{
			ptrbuf = 0;
			try
			{ lenbuf = is.read(inbuf); }
			catch (IOException e)
			{ throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c)
	{ return !(c >= 33 && c <= 126); }
	private int skip()
	{ int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd()
	{ return Double.parseDouble(ns()); }
	private char nc()
	{ return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b)))
		{ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private String nsl()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b) && b != ' '))
		{ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b)))
		{
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-')
		{
			minus = true;
			b = readByte();
		}

		while(true)
		{
			if(b >= '0' && b <= '9')
			{
				num = num * 10 + (b - '0');
			}else
			{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-')
		{
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9')
			{
				num = num * 10 + (b - '0');
			}else
			{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o)
	{ System.out.println(Arrays.deepToString(o)); }
}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Random;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		pw.println((A+B>=C)?"Yes":"No");
		pw.close();
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

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

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


import java.util.Scanner;

public class Sample1_6 {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc1 = new Scanner(System.in);
		String line1 = sc1.nextLine();

		String[] inputText = line1.split(" ");

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

		if (c < 0) {
			System.out.print("No");
		} else {
			System.out.print("Yes");
		}
	}
}


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc1 = new Scanner(System.in);
		String line1 = sc1.nextLine();

		String[] inputText = line1.split(" ");

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

		if (c < 0) {
			System.out.print("No");
		} else {
			System.out.print("Yes");
		}
	}


import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<Integer> one = nextIntArray();
      int A = one.get(0);
      int B = one.get(1);
      int C = one.get(2);
      myout((A * 2 + B * 2 >= C) ? "Yes" : "No");
	}
	//Method addition frame start

	//Method addition frame end
}


#include <cstdio>

using namespace std;

int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if (a + b >= c)
        printf("Yes");
    else
        printf("No");

    return 0;
}


#include <cstdio>
int main() {
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%s",a+b>=c ? "Yes" : "No");
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

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

	while (scanf("%d%d%d",&a,&b,&c)==3)
	{
		if (a+b>=c)
		{
			printf("Yes");
		}

		else
		{
			printf("No");
		}
	}

	return 0;
 }


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   int A,B,C;
   cin>>A>>B>>C;

   if(A+B>=C){
       cout<<"Yes"<<endl;
   }
   else {
       cout<<"NO"<<endl;
   }

}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int a, b, c;
  	cin >> a >> b >> c;
  	if (a + b > c)
      	cout << "Yes";
  	else
      	cout << "No";
    return 0;
}


#include<iostream>
using namespace std;
int main() {
	int a, b, c; cin >> a >> b >> c;
	if (a + b <= c)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


#include<stdio.h>
int main()
{
int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
if(a+b>=c) printf("Yes");
  else printf("No");

return 0;
}


#include <stdio.h>

int main(int argc, char **argv)
{
  int a,b,c;

  scanf("%d %d %d",&a,&b,&c);

  if(a + b >= c)
  {
    printf("Yes\n");
  }

  else
    printf("No\n");

  return 0;
}


#include <stdio.h>

int main(void) {
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);

  if (A + B >= C) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


#include <stdio.h>

int main(){
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  if(a + b < c) printf("Yes\n");
  else printf("No\n");
  return 0;
}


#include <stdio.h>

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

  scanf("%d %d %d",&a,&b,&c);

  if(a+b>c)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}


#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a+b > c) printf("Yes\n");
	else printf("No\n");
	return 0;
}


function main(input) {
    var a = input[0].split(" ")[0]-0;
    var b = input[0].split(" ")[1]-0;
    var c = input[0].split(" ")[2]-0;

    console.log(a+b>=c?"Yes":"No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


"use strict"

const Main =(input)=>{
const Array=input.split(" ")
const A=parseInt(Array[0],10)
const B=parseInt(Array[1],10)
const C=parseInt(Array[2],10)
const Answer= (A+B)>=C ?"Yes":"No"
console.log(Answer)
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


l = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')[0].split(' ')
A = l[0] * 1
B = l[1] * 1
X = l[2] * 1
console.log(A + B >= X ? 'Yes' : 'No')


function main(input) {
  const args = input.split('\n');
  const N = parseInt(args[0], 10);
  const M = parseInt(args[N + 1], 10);
  data = {};
  let blues = [];
  let reds = [];
  let ans;

  for (let i = 1; i <= N; i++) {
    blues.push(args[i]);
  }

  for (let i = (N + 2); i <= (N + M + 1) ; i++) {
  	reds.push(args[i]);
  }

  for (let i = 0; i < blues.length; i++) {
    key = blues[i];
    data[key] = data[key] ? data[key] + 1 : 1;
  }

  for (let i = 0; i < reds.length; i++) {
  	key = reds[i];
    data[key] = data[key] ? data[key] - 1 : -1;
  }

  for (key in data) {
    if (!ans || data[key] > ans) {
      ans = data[key];
    }
  }

  if (ans < 0) {
    console.log(0);
  } else {
    console.log(ans);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function main(input) {
  input = input.trim();
  const a = input.split(" ").map(Number);

  console.log((a[0]+a[1]>=a[2])?"YES":"NO");

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function main(input) {
  input = input.trim();
  const a = input.split(" ").map(Number);

  console.log((a[0]+a[1]>=a[2]) ? "YES":"NO");

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


package main

import (
	. "fmt"
)

// func init() { Println("----------------------------------------") }

func main() {
    var a, b, c int
    Scanf("%d %d %d", &a, &b, &c)
    if a + b >= c {
        Println("Yes")
    } else {
        Println("No")
    }
}


package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if a+b >= c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if a+b >= c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if 2*a + 2*b >= c {
		fmt.Println("Yes")
	}else{
		fmt.Println("No")
	}
}


#include <iostream>
#include <string.h>
using namespace std;

int main(int args, char *argv[])
{
    int a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;

    if (a + b >= c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if a+b > c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


A,B,C = gets.split.map(&:to_i)
puts A + B >= C ? 'Yes': 'No'


a, b, c = gets.chomp.split(" ").map(&:to_i)
puts a+b >= c ? "Yes" : "No"


A,B,C = gets.chomp.split.map {|n| n.to_i}
puts (if C <= A+B then
    'Yes'
else
    'No'
end)


a, b, c = gets.split.map &:to_i
puts c - a - b > 0 ? :Yes: :No


ary = []
n = gets.to_i
blue = n.times.map{gets.chomp}.group_by(&:itself).map{|k,v|[k,v.count]}.to_h
m = gets.to_i
red = m.times.map{gets.chomp}.group_by(&:itself).map{|k,v|[k,v.count]}.to_h
blue.each_key{|k|red.include?(k) ? ary<<blue[k]-red[k] : ary<<blue[k]}
puts ary.size==1 && ary.first<=0 ? 0 : ary.max


results = Hash.new
N = gets.to_i
N.times do
  blue = gets.strip
  results[blue].nil? ? results[blue] = 1 : results[blue] += 1
end
M = gets.to_i
M.times do
  red = gets.strip
  results[red].nil? ? results[red] = 1 : results[red] += 1
end
answer = results.max_by { |k, v| v }
puts answer[1] < 0 ? 0 : answer[1]


use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	let c = v[2];
	if a+b < c {
		println!("No");
	}else{
		println!("Yes");
	}
}


use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());
    let (a, b, c) = (it.next().unwrap(), it.next().unwrap(), it.next().unwrap());
    if a + b >= c {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

/*
The read function reads a string according to each one.
*/
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")
}

//main function
fn main() {
    let a:i64 = read();
    let b:i64 = read();
    let c:i64 = read();
    if a+b>=c{
	println!("Yes");
    }else{
	println!("No");
    }
}


#![allow(unused_imports)]
use std::cmp::{max, min};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

use nyan::*;

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

    let a: u64 = sc.read();
    let b: u64 = sc.read();
    let c: u64 = sc.read();

    if a + b <= c {
        println!("Yes");
    } else {
        println!("No");
    }
}

#[allow(dead_code)]
mod nyan {
    use std::cmp::*;
    use std::fmt::{Debug, Display};
    use std::io::{self, BufRead};
    use std::iter::FromIterator;
    use std::str::FromStr;

    // https://doc.rust-lang.org/1.39.0/src/core/num/mod.rs.html#4473-4523
    #[inline]
    pub fn is_ascii_whitespace(c: char) -> bool {
        match c {
            '\t' | '\n' | '\x0C' | '\r' | ' ' => true,
            _ => false,
        }
    }

    #[inline]
    pub fn is_ascii_linebreak(c: char) -> bool {
        match c {
            '\n' | '\r' => true,
            _ => false,
        }
    }

    struct Reader<R> {
        reader: R,
        buffer: String,
        cursor: usize,
    }

    impl<R: BufRead> Reader<R> {
        fn new(reader: R) -> Reader<R> {
            Reader {
                reader: reader,
                buffer: String::with_capacity(32),
                cursor: 0,
            }
        }

        #[inline]
        fn trim_start(&mut self) {
            match self.buffer[self.cursor..].find(|c| !is_ascii_whitespace(c)) {
                Some(l) => self.cursor += l,
                None => self.cursor = self.buffer.len(),
            }
        }

        fn prepare_buffer(&mut self) -> io::Result<()> {
            self.trim_start();

            while self.buffer.len() - self.cursor == 0 {
                self.buffer.clear();
                match self.reader.read_line(&mut self.buffer) {
                    Err(e) => return Err(e),
                    Ok(0) => return Err(io::Error::from(io::ErrorKind::UnexpectedEof)),
                    Ok(_) => {
                        self.cursor = 0;
                        self.trim_start();
                    }
                }
            }

            Ok(())
        }

        fn next_word(&mut self) -> io::Result<&str> {
            self.prepare_buffer()?;

            match self.buffer[self.cursor..].find(is_ascii_whitespace) {
                Some(l) => {
                    let start = self.cursor;
                    self.cursor += l;
                    Ok(&self.buffer[start..self.cursor])
                }
                None => Err(io::Error::from(io::ErrorKind::Other)),
            }
        }

        fn next_line(&mut self) -> io::Result<&str> {
            self.prepare_buffer()?;

            match self.buffer[self.cursor..].find(is_ascii_linebreak) {
                Some(l) => {
                    let start = self.cursor;
                    self.cursor += l;
                    Ok(&self.buffer[start..self.cursor])
                }
                None => Err(io::Error::from(io::ErrorKind::Other)),
            }
        }
    }

    pub struct Scanner<R> {
        reader: Reader<R>,
    }

    impl<R: BufRead> Scanner<R> {
        pub fn new(reader: R) -> Scanner<R> {
            Scanner {
                reader: Reader::new(reader),
            }
        }

        pub fn read<T>(&mut self) -> T
        where
            T: FromStr,
            <T as FromStr>::Err: Debug,
        {
            self.reader.next_word().unwrap().parse().unwrap()
        }

        pub fn read_vec<T, U>(&mut self, n: usize) -> T
        where
            T: FromIterator<U>,
            U: FromStr,
            <U as FromStr>::Err: Debug,
        {
            (0..n).map(|_| self.read()).collect()
        }

        pub fn read_vec2d<T, U, V>(&mut self, m: usize, n: usize) -> T
        where
            T: FromIterator<U>,
            U: FromIterator<V>,
            V: FromStr,
            <V as FromStr>::Err: Debug,
        {
            (0..m).map(|_| self.read_vec(n)).collect()
        }

        pub fn read_line<T: FromIterator<char>>(&mut self) -> T {
            self.reader.next_line().unwrap().chars().collect()
        }

        pub fn read_lines<T, U>(&mut self, n: usize) -> T
        where
            T: FromIterator<U>,
            U: FromIterator<char>,
        {
            (0..n).map(|_| self.read_line()).collect()
        }
    }

    pub fn print_vec<T: Display>(v: &[T]) {
        if v.is_empty() {
            return;
        }

        print!("{}", v[0]);
        for i in v.iter().skip(1) {
            print!(" {}", i);
        }
        println!();
    }

    // C++ like binary search functions (upper_bound, lower_bound, equal_range)
    pub trait BinarySearch<T> {
        fn lower_bound(&self, value: &T) -> usize;
        fn upper_bound(&self, value: &T) -> usize;
        fn equal_range(&self, value: &T) -> (usize, usize) {
            (self.lower_bound(value), self.upper_bound(value))
        }
    }

    impl<T: Ord> BinarySearch<T> for [T] {
        // https://en.cppreference.com/w/cpp/algorithm/lower_bound#Possible_implementation
        fn lower_bound(&self, value: &T) -> usize {
            let mut first = 0;
            let mut last = self.len();
            while last != first {
                let mid = (first + last) / 2;
                match self[mid].cmp(value) {
                    Ordering::Less => first = mid + 1,
                    _ => last = mid,
                }
            }
            first
        }

        // https://en.cppreference.com/w/cpp/algorithm/upper_bound#Possible_implementation
        fn upper_bound(&self, value: &T) -> usize {
            let mut first = 0;
            let mut last = self.len();
            while last != first {
                let mid = (first + last) / 2;
                match self[mid].cmp(value) {
                    Ordering::Greater => last = mid,
                    _ => first = mid + 1,
                }
            }
            first
        }
    }

    #[test]
    pub fn test_binary_search() {
        let data = vec![1, 1, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6];
        assert_eq!(data.lower_bound(&4), 7);
        assert_eq!(data.upper_bound(&4), 10);
    }

    // https://doc.rust-lang.org/std/cmp/struct.Reverse.html
    #[derive(PartialEq, Eq, Debug)]
    pub struct Rev<T>(pub T);

    impl<T: PartialOrd> PartialOrd for Rev<T> {
        fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
            other.0.partial_cmp(&self.0)
        }
    }

    impl<T: Ord> Ord for Rev<T> {
        fn cmp(&self, other: &Self) -> Ordering {
            other.0.cmp(&self.0)
        }
    }

    // Extended Euclidean algorithm
    // ax + by = gcd(x, y)
    pub fn extended_gcd(a: u64, b: u64) -> (u64, i64, i64) {
        if b == 0 {
            (a, 1, 0)
        } else {
            let (m, y, x) = extended_gcd(b, a % b);
            (m, x, y - (a / b) as i64 * x)
        }
    }

    pub fn gcd(a: u64, b: u64) -> u64 {
        if b == 0 {
            a
        } else {
            gcd(b, a % b)
        }
    }

    pub fn lcm(a: u64, b: u64) -> u64 {
        (a * b) / gcd(a, b)
    }

    // x^n (mod p)
    pub fn pow_mod(mut x: u64, mut n: u64, p: u64) -> u64 {
        let mut r = 1;
        while n > 0 {
            if n & 1 > 0 {
                r *= x;
                r %= p;
            }
            x *= x;
            x %= p;
            n >>= 1;
        }
        r
    }

    #[test]
    fn test_pow_mod() {
        assert_eq!(pow_mod(4, 13, 497), 445);
        assert_eq!(pow_mod(2, 90, 13), 12);
        assert_eq!(pow_mod(2, 99999999, 147), 134);
    }

    // a^{p-1} = 1 (mod p) (Fermat's little theorem)
    // a^{p - 2} * a = 1 → a^{-1} = a^{p-2}
    pub fn inv_mod(n: u64, p: u64) -> u64 {
        pow_mod(n, p - 2, p)
    }

    // s * (s + 1) * .. * t (mod p)
    pub fn prod_mod(s: u64, t: u64, p: u64) -> u64 {
        (s..t + 1).fold(1, |acc, x| acc * x % p)
    }

    // nCk (mod p)
    pub fn comb_mod(n: u64, k: u64, p: u64) -> u64 {
        // nCk = n! / (k! * (n - k)!)
        //     = ((n-k+1) * (n-k+2) * ... * n) * inv(k!)
        prod_mod(n - k + 1, n, p) * inv_mod(prod_mod(1, k, p), p) % p
    }

    #[inline]
    pub fn minmax<T: Ord>(a: T, b: T) -> (T, T) {
        if a < b {
            (a, b)
        } else {
            (b, a)
        }
    }

    #[test]
    fn test_minmax() {
        assert_eq!(minmax(1, 3), (1, 3));
        assert_eq!(minmax(3, 1), (1, 3));
    }

    pub struct UnionFind {
        n: usize,
        root: Vec<usize>,
        rank: Vec<usize>,
        size: Vec<usize>,
    }

    impl UnionFind {
        pub fn new(n: usize) -> UnionFind {
            UnionFind {
                n: n,
                root: (0..n).collect(),
                rank: vec![0; n],
                size: vec![1; n],
            }
        }

        pub fn root(&mut self, x: usize) -> usize {
            let r = self.root[x];
            if r == x {
                r
            } else {
                self.root[x] = self.root(r);
                self.root[x]
            }
        }

        pub fn merge(&mut self, x: usize, y: usize) {
            let rx = self.root(x);
            let ry = self.root(y);
            if rx == ry {
                return;
            }

            if self.rank[rx] < self.rank[ry] {
                self.root[rx] = ry;
                self.size[ry] += self.size[rx];
            } else {
                self.root[ry] = rx;
                self.size[rx] += self.size[ry];
                if self.rank[rx] == self.rank[ry] {
                    self.rank[rx] += 1;
                }
            }
        }

        pub fn size(&mut self, x: usize) -> usize {
            let rx = self.root(x);
            self.size[rx]
        }
    }
}


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

pub 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")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let a = read::<i64>();
  let b = read::<i64>();
  let c = read::<i64>();
  let mut ans = "No";
  if c < a + b {
    ans = "Yes";
  }

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


use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i64 = input();
    let b: i64 = input();
    let c: i64 = input();
    println!("{}", if a + b <= c { "Yes" } else { "No" });
}


let i=readLine()!.characters.split(" ").map{Int(String($0))!};print(i[0]+i[1]<i[2] ?"No":"Yes")


import Foundation

let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ") //ブランクで区切られている場合

var A = Int(split[0])!
//String -> Intの型変換はnilが返る可能性があるので、ラップされたOptional<Int>型が返るので強制アンラップ
var B = Int(split[1])!
var C = Int(split[2])!

if (A+B >= C){
    print("Yes")
}else{
    print("No")
}


//
//  main.swift
//
//  Created by sun-yryr
//  Copyright © 2019 sun-yryr. All rights reserved.
//

import Foundation

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}

func readInt(separator s: Character = " ") -> [Int] {return readLine()!.split(separator: s).map({Int($0)!})}
func readDouble(separator s: Character = " ") -> [Double] {return readLine()!.split(separator: s).map({Double($0)!})}
func readElement(separator s: Character = " ") -> [String] {return readLine()!.split(separator: s).map({String($0)})}

extension String {
    func at(_ i: Int) -> Character {
        precondition(0 <= i && i < self.count)
        return self[self.index(self.startIndex, offsetBy: i)]
    }
}

func main() {
    let (A, B, C) = *readInt()
    if (C <= (A+B)) {
        print("Yes")
    } else {
        print("No")
    }
}
main()


print("YES")


//
//  main.swift
//
//  Created by sun-yryr
//  Copyright © 2019 sun-yryr. All rights reserved.
//

import Foundation

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}

func readInt(separator s: Character = " ") -> [Int] {return readLine()!.split(separator: s).map({Int($0)!})}
func readDouble(separator s: Character = " ") -> [Double] {return readLine()!.split(separator: s).map({Double($0)!})}
func readElement(separator s: Character = " ") -> [String] {return readLine()!.split(separator: s).map({String($0)})}

extension String {
    func at(_ i: Int) -> Character {
        precondition(0 <= i && i < self.count)
        return self[self.index(self.startIndex, offsetBy: i)]
    }
}

func main() {
    let (A, B, C) = *readInt()
    if (C <= (A+B)) {
        print("YES")
    } else {
        print("NO")
    }
}
main()


import * as fs from 'fs'
const [input] = fs.readFileSync('/dev/stdin', 'utf8').split(/\r?\n/)
const [a, b, c] = input.split(' ').map(v => parseInt(v))

console.log(a + b >= c ? 'Yes' : 'No')


const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,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 ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  out(nin()+nin()>=nin()?'Yes':'No')
}
main()


const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [a, b, c] = stdin.split('\n')[0].split(' ').map(Number)

const res = a+b >= c ? 'Yes' : 'No'

console.log(res)


declare var process: any;
process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on("data", function(chunk: any) {
  var lines = chunk
    .toString()
    .split("\n")[0]
    .split(" ");
  console.log(lines[0]);
  console.log(lines[1]);
  console.log(lines[2]);
  if (parseInt(lines[0]) + parseInt(lines[1]) >= parseInt(lines[2])) {
    console.log("Yes");
  } else {
    console.log("No");
  }
});


declare var process: any;

function Main(input: string[]) {
  if (parseInt(input[4]) <= parseInt(input[2]) + parseInt(input[3])) {
    console.log("Yes");
  } else {
    console.log("No");
  }
}
Main(process.argv);


declare var process: any;

if (
  parseInt(process.argv[4]) <=
  parseInt(process.argv[2]) + parseInt(process.argv[3])
) {
  console.log("Yes");
} else {
  console.log("No");
}


n, T = map(int, input().split())
tm = 1001
for i in range(n):
    c, t = map(int, input().split())
    if t <= T:
        tm = min(tm, c)
if tm == 1001:
    print("TLE")
else:
    print(tm)


Tmp = []
Tmp = input().rstrip().split(' ')

nN = int(Tmp[0])
nT = int(Tmp[1])

nCost = 1001
nAns = 0

for i in range(nN):
  Tmp = input().rstrip().split(' ')

  nTmpCost = int(Tmp[0])
  nTmpT = int(Tmp[1])

  if nTmpT <= nT and nTmpCost < nCost:
    nCost = nTmpCost
    nAns = i+1

if nAns == 0:
  print('TLE')
else:
  print(nCost)


N, T = map(int, input().split())
ans = []
for _ in range(N):
    c, t = map(int, input().split())
    if t <= T:
        ans.append(c)
    else:
        ans.append(999999)
ans = sorted(ans)
if ans[0] == 999999:
    print("TLE")
else:
    print(ans[0])


ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
import sys
n,T = ma()
ans=10**15
for i in range(n):
    c,t=ma()
    if t<T:
        ans=min(ans,c)
if ans==10**15:
    print("TLE")
else:print(ans)


N,T=list(map(int, input().split()))
a=10**5
for _ in range(N):
  c,t=list(map(int, input().split()))
  if t<=T:
    a=min(c,a)
if a==10**5:
  print('TLE')
else:
  print(c)


N,T=list(map(int, input().split()))
a=10**5
for _ in range(N):
  c,t=list(map(int, input().split()))
  if t<=T:
    a=min(c.a)
if a==10**5:
  print('TLE')
else:
  print(c)