import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int h[] = new int[K+1];
    int landCt =0;
    int answer=0;
    h[0]=0;
    for(int i=1;i<=K;i++){
      h[i] = sc.nextInt();
    }
    for(int i=0;i<101;i++){
      landCt=0;
      for(int j=0;j<K;j++){
        if(h[j]==0&&h[j+1]>0){
          landCt=landCt+1;
        }
      }
      answer = answer + landCt;
      oneMinus(h);
    }
      System.out.println(answer);   
  }
  
  public static void oneMinus(int[] h){
    for(int i=0;i<h.length;i++){
      if(h[i]!=0){
        h[i]=h[i]-1;
      }
    }
  }
  
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int h[] = new int[K+1];
    int landCt =0;
    int answer=0;
    h[0]=0;
    for(int i=1;i<=K;i++){
      h[i] = sc.nextInt();
    }
    for(int i=0;i<101;i++){
      landCt=0;
      for(int j=0;j<K;j++){
        if(h[j]==0&&h[j+1]>0){
          landCt=landCt+1;
        }
      }
      answer = answer + landCt;
      oneMinus(h);
    }
      System.out.println(answer);   
  }
  
  public static void oneMinus(int[] h){
    for(int i=0;i<h.length;i++){
      if(h[i]!=0){
        h[i]=h[i]-1;
      }
    }
  }
  
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int h[] = new int[K+1];
    int landCt =0;
    int answer=0;
    h[0]=0;
    for(int i=1;i<=K;i++){
      h[i] = sc.nextInt();
    }
    for(int i=0;i<101;i++){
      landCt=0;
      for(int j=0;j<K;j++){
        if(h[j]==0&&h[j+1]>0){
          landCt=landCt+1;
        }
      }
      answer = answer + landCt;
      oneMinus(h);
    }
      System.out.println(answer);   
  } main {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int h[] = new int[K+1];
    int landCt =0;
    int answer=0;
    h[0]=0;
    for(int i=1;i<=K;i++){
      h[i] = sc.nextInt();
    }
    for(int i=0;i<101;i++){
      landCt=0;
      for(int j=0;j<K;j++){
        if(h[j]==0&&h[j+1]>0){
          landCt=landCt+1;
        }
      }
      answer = answer + landCt;
      oneMinus(h);
    }
      System.out.println(answer);   
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc int h[] = new int[K+1]; h new int[K+1] K+1 K 1 int landCt =0; landCt 0 int answer=0; answer 0 h[0]=0 h[0] h 0 0 for(int i=1;i<=K;i++){
      h[i] = sc.nextInt();
    } int i=1; int i=1; i 1 i<=K i K i++ i++ i {
      h[i] = sc.nextInt();
    } {
      h[i] = sc.nextInt();
    } h[i] = sc.nextInt() h[i] h i sc.nextInt() sc.nextInt sc for(int i=0;i<101;i++){
      landCt=0;
      for(int j=0;j<K;j++){
        if(h[j]==0&&h[j+1]>0){
          landCt=landCt+1;
        }
      }
      answer = answer + landCt;
      oneMinus(h);
    } int i=0; int i=0; i 0 i<101 i 101 i++ i++ i {
      landCt=0;
      for(int j=0;j<K;j++){
        if(h[j]==0&&h[j+1]>0){
          landCt=landCt+1;
        }
      }
      answer = answer + landCt;
      oneMinus(h);
    } {
      landCt=0;
      for(int j=0;j<K;j++){
        if(h[j]==0&&h[j+1]>0){
          landCt=landCt+1;
        }
      }
      answer = answer + landCt;
      oneMinus(h);
    } landCt=0 landCt 0 for(int j=0;j<K;j++){
        if(h[j]==0&&h[j+1]>0){
          landCt=landCt+1;
        }
      } int j=0; int j=0; j 0 j<K j K j++ j++ j {
        if(h[j]==0&&h[j+1]>0){
          landCt=landCt+1;
        }
      } {
        if(h[j]==0&&h[j+1]>0){
          landCt=landCt+1;
        }
      } if(h[j]==0&&h[j+1]>0){
          landCt=landCt+1;
        } h[j]==0&&h[j+1]>0 h[j]==0 h[j] h j 0 h[j+1]>0 h[j+1] h j+1 j 1 0 {
          landCt=landCt+1;
        } landCt=landCt+1 landCt landCt+1 landCt 1 answer = answer + landCt answer answer + landCt answer landCt oneMinus(h) oneMinus h System.out.println(answer) System.out.println System.out System System.out answer String[] args args public static void oneMinus(int[] h){
    for(int i=0;i<h.length;i++){
      if(h[i]!=0){
        h[i]=h[i]-1;
      }
    }
  } oneMinus {
    for(int i=0;i<h.length;i++){
      if(h[i]!=0){
        h[i]=h[i]-1;
      }
    }
  } for(int i=0;i<h.length;i++){
      if(h[i]!=0){
        h[i]=h[i]-1;
      }
    } int i=0; int i=0; i 0 i<h.length i h.length h h.length i++ i++ i {
      if(h[i]!=0){
        h[i]=h[i]-1;
      }
    } {
      if(h[i]!=0){
        h[i]=h[i]-1;
      }
    } if(h[i]!=0){
        h[i]=h[i]-1;
      } h[i]!=0 h[i] h i 0 {
        h[i]=h[i]-1;
      } h[i]=h[i]-1 h[i] h i h[i]-1 h[i] h i 1 int[] h h public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int h[] = new int[K+1];
    int landCt =0;
    int answer=0;
    h[0]=0;
    for(int i=1;i<=K;i++){
      h[i] = sc.nextInt();
    }
    for(int i=0;i<101;i++){
      landCt=0;
      for(int j=0;j<K;j++){
        if(h[j]==0&&h[j+1]>0){
          landCt=landCt+1;
        }
      }
      answer = answer + landCt;
      oneMinus(h);
    }
      System.out.println(answer);   
  }
  
  public static void oneMinus(int[] h){
    for(int i=0;i<h.length;i++){
      if(h[i]!=0){
        h[i]=h[i]-1;
      }
    }
  }
  
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int h[] = new int[K+1];
    int landCt =0;
    int answer=0;
    h[0]=0;
    for(int i=1;i<=K;i++){
      h[i] = sc.nextInt();
    }
    for(int i=0;i<101;i++){
      landCt=0;
      for(int j=0;j<K;j++){
        if(h[j]==0&&h[j+1]>0){
          landCt=landCt+1;
        }
      }
      answer = answer + landCt;
      oneMinus(h);
    }
      System.out.println(answer);   
  }
  
  public static void oneMinus(int[] h){
    for(int i=0;i<h.length;i++){
      if(h[i]!=0){
        h[i]=h[i]-1;
      }
    }
  }
  
} Main
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int h[] = new int[K+1];
    int landCt =0;
    int answer=0;
    h[0]=0;
    for(int i=1;i<=K;i++){
      h[i] = sc.nextInt();
    }
    for(int i=0;i<101;i++){
      landCt=0;
      for(int j=0;j<K;j++){
        if(h[j]==0&&h[j+1]>0){
          landCt=landCt+1;
        }
      }
      answer = answer + landCt;
      oneMinus(h);
    }
      System.out.println(answer);   
  }
  
  public static void oneMinus(int[] h){
    for(int i=0;i<h.length;i++){
      if(h[i]!=0){
        h[i]=h[i]-1;
      }
    }
  }
  
}