function Main(input){
  const splitted = input.split('\n');
  const N = parseInt(splitted[0]);
  const h = splitted[1].split(' ').map(elem => parseInt(elem));

  var total = 0;
  for(var i=1;i<=100;i++){
    var nowCounting = false;
    for(var j=0;j<N;j++){
      if(nowCounting){
        if(h[j] < i){
          nowCounting = false;
        }
      }else{
        if(h[j] >= i){
          nowCounting = true;
          total++;
        }
      }
    }
  }
  console.log(total);
}

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