// Learn more about F# at http://fsharp.org
// See the 'F# Tutorial' project for more help.

[<EntryPoint>]
let main argv = 
    let numOfProblems = stdin.ReadLine() |> int

    let scoreOfProblems = stdin.ReadLine().Split(' ') |> Array.map int

    let maxScore = scoreOfProblems |> Array.max
    let minScore = scoreOfProblems |> Array.min

    let count = [for i in minScore..maxScore -> i]
              |> List.map(fun x -> scoreOfProblems |> Array.partition(fun y -> y>=x))
              |> List.filter(fun (arc, abc) -> arc.Length = abc.Length)
              |> List.length

    printfn "%d" count

    0 // return an integer exit code
