fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val h = readLine()!!.split(" ").map { it.toInt() }

    val goal = (1..100).map{ y ->
        (0..n-1).map { if( y<=h[it] ) '1' else '0'}.joinToString("")
    }

    val ans = goal.map{
        it.split("0").filter { it.length>0 }.size
    }.sum()

    println(ans)
}