import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N;
    N = sc.nextInt();
    int h[] = new int[N];
    boolean exi = false;
    int ans = 0;
    for(int i=0; i<N; i++) h[i] = sc.nextInt();
    for(int i=1; i<=100; i++){
      for(int j=0; j<N; j++){
        if(h[j] >= i){
          if(exi == false){
            ans++;
            exi = true;
          }
        }else{
          exi = false;
        }
      }
      exi = false;
    }
    System.out.println(ans);
                               
  }
} import java.util.*; util.* java class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N;
    N = sc.nextInt();
    int h[] = new int[N];
    boolean exi = false;
    int ans = 0;
    for(int i=0; i<N; i++) h[i] = sc.nextInt();
    for(int i=1; i<=100; i++){
      for(int j=0; j<N; j++){
        if(h[j] >= i){
          if(exi == false){
            ans++;
            exi = true;
          }
        }else{
          exi = false;
        }
      }
      exi = false;
    }
    System.out.println(ans);
                               
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N;
    N = sc.nextInt();
    int h[] = new int[N];
    boolean exi = false;
    int ans = 0;
    for(int i=0; i<N; i++) h[i] = sc.nextInt();
    for(int i=1; i<=100; i++){
      for(int j=0; j<N; j++){
        if(h[j] >= i){
          if(exi == false){
            ans++;
            exi = true;
          }
        }else{
          exi = false;
        }
      }
      exi = false;
    }
    System.out.println(ans);
                               
  } main {
    Scanner sc = new Scanner(System.in);
    int N;
    N = sc.nextInt();
    int h[] = new int[N];
    boolean exi = false;
    int ans = 0;
    for(int i=0; i<N; i++) h[i] = sc.nextInt();
    for(int i=1; i<=100; i++){
      for(int j=0; j<N; j++){
        if(h[j] >= i){
          if(exi == false){
            ans++;
            exi = true;
          }
        }else{
          exi = false;
        }
      }
      exi = false;
    }
    System.out.println(ans);
                               
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N; N N = sc.nextInt() N sc.nextInt() sc.nextInt sc int h[] = new int[N]; h new int[N] N boolean exi = false; exi false int ans = 0; ans 0 for(int i=0; i<N; i++) h[i] = sc.nextInt(); int i=0; int i=0; i 0 i<N i N i++ i++ i h[i] = sc.nextInt(); h[i] = sc.nextInt() h[i] h i sc.nextInt() sc.nextInt sc for(int i=1; i<=100; i++){
      for(int j=0; j<N; j++){
        if(h[j] >= i){
          if(exi == false){
            ans++;
            exi = true;
          }
        }else{
          exi = false;
        }
      }
      exi = false;
    } int i=1; int i=1; i 1 i<=100 i 100 i++ i++ i {
      for(int j=0; j<N; j++){
        if(h[j] >= i){
          if(exi == false){
            ans++;
            exi = true;
          }
        }else{
          exi = false;
        }
      }
      exi = false;
    } {
      for(int j=0; j<N; j++){
        if(h[j] >= i){
          if(exi == false){
            ans++;
            exi = true;
          }
        }else{
          exi = false;
        }
      }
      exi = false;
    } for(int j=0; j<N; j++){
        if(h[j] >= i){
          if(exi == false){
            ans++;
            exi = true;
          }
        }else{
          exi = false;
        }
      } int j=0; int j=0; j 0 j<N j N j++ j++ j {
        if(h[j] >= i){
          if(exi == false){
            ans++;
            exi = true;
          }
        }else{
          exi = false;
        }
      } {
        if(h[j] >= i){
          if(exi == false){
            ans++;
            exi = true;
          }
        }else{
          exi = false;
        }
      } if(h[j] >= i){
          if(exi == false){
            ans++;
            exi = true;
          }
        }else{
          exi = false;
        } h[j] >= i h[j] h j i {
          if(exi == false){
            ans++;
            exi = true;
          }
        } if(exi == false){
            ans++;
            exi = true;
          } exi == false exi false {
            ans++;
            exi = true;
          } ans++ ans exi = true exi true {
          exi = false;
        } exi = false exi false exi = false exi false System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N;
    N = sc.nextInt();
    int h[] = new int[N];
    boolean exi = false;
    int ans = 0;
    for(int i=0; i<N; i++) h[i] = sc.nextInt();
    for(int i=1; i<=100; i++){
      for(int j=0; j<N; j++){
        if(h[j] >= i){
          if(exi == false){
            ans++;
            exi = true;
          }
        }else{
          exi = false;
        }
      }
      exi = false;
    }
    System.out.println(ans);
                               
  }
}