COCI '07 Contest 1 #3 Prinova

View as PDF

Points: 7 (partial)
Time limit: 0.6s
Memory limit: 32M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Brojko and Brojana are happily married with little boys. The boys are named with distinct even integers .

Brojko and Brojana are expecting an addition to their family and have to come up with a nice name for the little girl. They have decided that the name will be an odd integer in the range . Because they find all integers in that range equally beautiful, they have decided to choose the number which maximizes the distance to the name of the closest of the boys.

More precisely, they seek an odd integer such that the expression is as large as possible.

Write a program that determines the name for the little girl. If there are multiple solutions, output any of them.

Input Specification

The first line contains an integer , the number of boys. The second line contains distinct even integers, the names of the boys. The integers will be less than . The third line contains the integers and , the range of names they are considering for the girl.

Output Specification

Output an integer, the name for the little girl.

Sample Input 1

3
2 6 16
20 50

Sample Output 1

49

Sample Input 2

3
2 6 16
3 15

Sample Output 2

11

Sample Input 3

3
2 6 16
1 7

Sample Output 3

5