import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int[] h = new int[n+2];
  h[0] = 0;
  h[n+1] = 0;
  for(int i = 0;i < n;i++){
    h[i+1] = sc.nextInt();
  }
  int cnt = 0;
  for(;;){
    int a = 200;
    int b = 200;
    for(int i = 0;i < n+2;i++){
      if(h[i] != 0){
        a = i;
        break;
      }
    }
    if(a == 200)break;
    for(int i = a;i < n+2;i++){
      if(h[i] == 0){
        b = i;
        break;
      }
    }
    for(int i = a;i < b;i++){
      h[i]--;
    }
    cnt++;
  }
  System.out.println(cnt);
}} import java.util.*; util.* java public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int[] h = new int[n+2];
  h[0] = 0;
  h[n+1] = 0;
  for(int i = 0;i < n;i++){
    h[i+1] = sc.nextInt();
  }
  int cnt = 0;
  for(;;){
    int a = 200;
    int b = 200;
    for(int i = 0;i < n+2;i++){
      if(h[i] != 0){
        a = i;
        break;
      }
    }
    if(a == 200)break;
    for(int i = a;i < n+2;i++){
      if(h[i] == 0){
        b = i;
        break;
      }
    }
    for(int i = a;i < b;i++){
      h[i]--;
    }
    cnt++;
  }
  System.out.println(cnt);
}} Main public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int[] h = new int[n+2];
  h[0] = 0;
  h[n+1] = 0;
  for(int i = 0;i < n;i++){
    h[i+1] = sc.nextInt();
  }
  int cnt = 0;
  for(;;){
    int a = 200;
    int b = 200;
    for(int i = 0;i < n+2;i++){
      if(h[i] != 0){
        a = i;
        break;
      }
    }
    if(a == 200)break;
    for(int i = a;i < n+2;i++){
      if(h[i] == 0){
        b = i;
        break;
      }
    }
    for(int i = a;i < b;i++){
      h[i]--;
    }
    cnt++;
  }
  System.out.println(cnt);
} main {
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int[] h = new int[n+2];
  h[0] = 0;
  h[n+1] = 0;
  for(int i = 0;i < n;i++){
    h[i+1] = sc.nextInt();
  }
  int cnt = 0;
  for(;;){
    int a = 200;
    int b = 200;
    for(int i = 0;i < n+2;i++){
      if(h[i] != 0){
        a = i;
        break;
      }
    }
    if(a == 200)break;
    for(int i = a;i < n+2;i++){
      if(h[i] == 0){
        b = i;
        break;
      }
    }
    for(int i = a;i < b;i++){
      h[i]--;
    }
    cnt++;
  }
  System.out.println(cnt);
} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] h = new int[n+2]; h new int[n+2] n+2 n 2 h[0] = 0 h[0] h 0 0 h[n+1] = 0 h[n+1] h n+1 n 1 0 for(int i = 0;i < n;i++){
    h[i+1] = sc.nextInt();
  } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
    h[i+1] = sc.nextInt();
  } {
    h[i+1] = sc.nextInt();
  } h[i+1] = sc.nextInt() h[i+1] h i+1 i 1 sc.nextInt() sc.nextInt sc int cnt = 0; cnt 0 for(;;){
    int a = 200;
    int b = 200;
    for(int i = 0;i < n+2;i++){
      if(h[i] != 0){
        a = i;
        break;
      }
    }
    if(a == 200)break;
    for(int i = a;i < n+2;i++){
      if(h[i] == 0){
        b = i;
        break;
      }
    }
    for(int i = a;i < b;i++){
      h[i]--;
    }
    cnt++;
  } ; {
    int a = 200;
    int b = 200;
    for(int i = 0;i < n+2;i++){
      if(h[i] != 0){
        a = i;
        break;
      }
    }
    if(a == 200)break;
    for(int i = a;i < n+2;i++){
      if(h[i] == 0){
        b = i;
        break;
      }
    }
    for(int i = a;i < b;i++){
      h[i]--;
    }
    cnt++;
  } {
    int a = 200;
    int b = 200;
    for(int i = 0;i < n+2;i++){
      if(h[i] != 0){
        a = i;
        break;
      }
    }
    if(a == 200)break;
    for(int i = a;i < n+2;i++){
      if(h[i] == 0){
        b = i;
        break;
      }
    }
    for(int i = a;i < b;i++){
      h[i]--;
    }
    cnt++;
  } int a = 200; a 200 int b = 200; b 200 for(int i = 0;i < n+2;i++){
      if(h[i] != 0){
        a = i;
        break;
      }
    } int i = 0; int i = 0; i 0 i < n+2 i n+2 n 2 i++ i++ i {
      if(h[i] != 0){
        a = i;
        break;
      }
    } {
      if(h[i] != 0){
        a = i;
        break;
      }
    } if(h[i] != 0){
        a = i;
        break;
      } h[i] != 0 h[i] h i 0 {
        a = i;
        break;
      } a = i a i break; if(a == 200)break; a == 200 a 200 break; for(int i = a;i < n+2;i++){
      if(h[i] == 0){
        b = i;
        break;
      }
    } int i = a; int i = a; i a i < n+2 i n+2 n 2 i++ i++ i {
      if(h[i] == 0){
        b = i;
        break;
      }
    } {
      if(h[i] == 0){
        b = i;
        break;
      }
    } if(h[i] == 0){
        b = i;
        break;
      } h[i] == 0 h[i] h i 0 {
        b = i;
        break;
      } b = i b i break; for(int i = a;i < b;i++){
      h[i]--;
    } int i = a; int i = a; i a i < b i b i++ i++ i {
      h[i]--;
    } {
      h[i]--;
    } h[i]-- h[i] h i cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int[] h = new int[n+2];
  h[0] = 0;
  h[n+1] = 0;
  for(int i = 0;i < n;i++){
    h[i+1] = sc.nextInt();
  }
  int cnt = 0;
  for(;;){
    int a = 200;
    int b = 200;
    for(int i = 0;i < n+2;i++){
      if(h[i] != 0){
        a = i;
        break;
      }
    }
    if(a == 200)break;
    for(int i = a;i < n+2;i++){
      if(h[i] == 0){
        b = i;
        break;
      }
    }
    for(int i = a;i < b;i++){
      h[i]--;
    }
    cnt++;
  }
  System.out.println(cnt);
}} public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int[] h = new int[n+2];
  h[0] = 0;
  h[n+1] = 0;
  for(int i = 0;i < n;i++){
    h[i+1] = sc.nextInt();
  }
  int cnt = 0;
  for(;;){
    int a = 200;
    int b = 200;
    for(int i = 0;i < n+2;i++){
      if(h[i] != 0){
        a = i;
        break;
      }
    }
    if(a == 200)break;
    for(int i = a;i < n+2;i++){
      if(h[i] == 0){
        b = i;
        break;
      }
    }
    for(int i = a;i < b;i++){
      h[i]--;
    }
    cnt++;
  }
  System.out.println(cnt);
}} Main
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int[] h = new int[n+2];
  h[0] = 0;
  h[n+1] = 0;
  for(int i = 0;i < n;i++){
    h[i+1] = sc.nextInt();
  }
  int cnt = 0;
  for(;;){
    int a = 200;
    int b = 200;
    for(int i = 0;i < n+2;i++){
      if(h[i] != 0){
        a = i;
        break;
      }
    }
    if(a == 200)break;
    for(int i = a;i < n+2;i++){
      if(h[i] == 0){
        b = i;
        break;
      }
    }
    for(int i = a;i < b;i++){
      h[i]--;
    }
    cnt++;
  }
  System.out.println(cnt);
}}