import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] h = new int[n+1];
        int max = 0;
        for(int i = 0; i < n; i++){
            h[i] = scanner.nextInt();
            max = Math.max(max, h[i]);
        }
        int count = 0;
        for(int i = 1; i <= max; i++){
            for(int j = 0; j < n; j++){
                if(h[j] >= i && h[j+1] < i){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
} import java.util.*; util.* java class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] h = new int[n+1];
        int max = 0;
        for(int i = 0; i < n; i++){
            h[i] = scanner.nextInt();
            max = Math.max(max, h[i]);
        }
        int count = 0;
        for(int i = 1; i <= max; i++){
            for(int j = 0; j < n; j++){
                if(h[j] >= i && h[j+1] < i){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] h = new int[n+1];
        int max = 0;
        for(int i = 0; i < n; i++){
            h[i] = scanner.nextInt();
            max = Math.max(max, h[i]);
        }
        int count = 0;
        for(int i = 1; i <= max; i++){
            for(int j = 0; j < n; j++){
                if(h[j] >= i && h[j+1] < i){
                    count++;
                }
            }
        }
        System.out.println(count);
    } main {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] h = new int[n+1];
        int max = 0;
        for(int i = 0; i < n; i++){
            h[i] = scanner.nextInt();
            max = Math.max(max, h[i]);
        }
        int count = 0;
        for(int i = 1; i <= max; i++){
            for(int j = 0; j < n; j++){
                if(h[j] >= i && h[j+1] < i){
                    count++;
                }
            }
        }
        System.out.println(count);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int[] h = new int[n+1]; h new int[n+1] n+1 n 1 int max = 0; max 0 for(int i = 0; i < n; i++){
            h[i] = scanner.nextInt();
            max = Math.max(max, h[i]);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            h[i] = scanner.nextInt();
            max = Math.max(max, h[i]);
        } {
            h[i] = scanner.nextInt();
            max = Math.max(max, h[i]);
        } h[i] = scanner.nextInt() h[i] h i scanner.nextInt() scanner.nextInt scanner max = Math.max(max, h[i]) max Math.max(max, h[i]) Math.max Math max h[i] h i int count = 0; count 0 for(int i = 1; i <= max; i++){
            for(int j = 0; j < n; j++){
                if(h[j] >= i && h[j+1] < i){
                    count++;
                }
            }
        } int i = 1; int i = 1; i 1 i <= max i max i++ i++ i {
            for(int j = 0; j < n; j++){
                if(h[j] >= i && h[j+1] < i){
                    count++;
                }
            }
        } {
            for(int j = 0; j < n; j++){
                if(h[j] >= i && h[j+1] < i){
                    count++;
                }
            }
        } for(int j = 0; j < n; j++){
                if(h[j] >= i && h[j+1] < i){
                    count++;
                }
            } int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
                if(h[j] >= i && h[j+1] < i){
                    count++;
                }
            } {
                if(h[j] >= i && h[j+1] < i){
                    count++;
                }
            } if(h[j] >= i && h[j+1] < i){
                    count++;
                } h[j] >= i && h[j+1] < i h[j] >= i h[j] h j i h[j+1] < i h[j+1] h j+1 j 1 i {
                    count++;
                } count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] h = new int[n+1];
        int max = 0;
        for(int i = 0; i < n; i++){
            h[i] = scanner.nextInt();
            max = Math.max(max, h[i]);
        }
        int count = 0;
        for(int i = 1; i <= max; i++){
            for(int j = 0; j < n; j++){
                if(h[j] >= i && h[j+1] < i){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}