import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] h = new int[n];
        int[] curH = new int[n];
        
        for (int i = 0; i < n; i++) {
            h[i] = scanner.nextInt();
        }
        int count = 0;
        outer:
        while (true) {
            int start = 0, end = 0;
            for (start = 0; start < n; start++) {
                if (curH[start] < h[start]) {
                    break;
                }
            }
            if (start >= n) {
                break;
            }
            count++;
            int i;
            for (i = start; i < n; i++) {
                if (curH[i] < h[i]) {
                    curH[i]++;
                } else {
                    break;
                }
            }
        }
        
        System.out.println(count);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] h = new int[n];
        int[] curH = new int[n];
        
        for (int i = 0; i < n; i++) {
            h[i] = scanner.nextInt();
        }
        int count = 0;
        outer:
        while (true) {
            int start = 0, end = 0;
            for (start = 0; start < n; start++) {
                if (curH[start] < h[start]) {
                    break;
                }
            }
            if (start >= n) {
                break;
            }
            count++;
            int i;
            for (i = start; i < n; i++) {
                if (curH[i] < h[i]) {
                    curH[i]++;
                } else {
                    break;
                }
            }
        }
        
        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];
        int[] curH = new int[n];
        
        for (int i = 0; i < n; i++) {
            h[i] = scanner.nextInt();
        }
        int count = 0;
        outer:
        while (true) {
            int start = 0, end = 0;
            for (start = 0; start < n; start++) {
                if (curH[start] < h[start]) {
                    break;
                }
            }
            if (start >= n) {
                break;
            }
            count++;
            int i;
            for (i = start; i < n; i++) {
                if (curH[i] < h[i]) {
                    curH[i]++;
                } else {
                    break;
                }
            }
        }
        
        System.out.println(count);
    } main {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] h = new int[n];
        int[] curH = new int[n];
        
        for (int i = 0; i < n; i++) {
            h[i] = scanner.nextInt();
        }
        int count = 0;
        outer:
        while (true) {
            int start = 0, end = 0;
            for (start = 0; start < n; start++) {
                if (curH[start] < h[start]) {
                    break;
                }
            }
            if (start >= n) {
                break;
            }
            count++;
            int i;
            for (i = start; i < n; i++) {
                if (curH[i] < h[i]) {
                    curH[i]++;
                } else {
                    break;
                }
            }
        }
        
        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]; h new int[n] n int[] curH = new int[n]; curH new int[n] n for (int i = 0; i < n; i++) {
            h[i] = scanner.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            h[i] = scanner.nextInt();
        } {
            h[i] = scanner.nextInt();
        } h[i] = scanner.nextInt() h[i] h i scanner.nextInt() scanner.nextInt scanner int count = 0; count 0 System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] h = new int[n];
        int[] curH = new int[n];
        
        for (int i = 0; i < n; i++) {
            h[i] = scanner.nextInt();
        }
        int count = 0;
        outer:
        while (true) {
            int start = 0, end = 0;
            for (start = 0; start < n; start++) {
                if (curH[start] < h[start]) {
                    break;
                }
            }
            if (start >= n) {
                break;
            }
            count++;
            int i;
            for (i = start; i < n; i++) {
                if (curH[i] < h[i]) {
                    curH[i]++;
                } else {
                    break;
                }
            }
        }
        
        System.out.println(count);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] h = new int[n];
        int[] curH = new int[n];
        
        for (int i = 0; i < n; i++) {
            h[i] = scanner.nextInt();
        }
        int count = 0;
        outer:
        while (true) {
            int start = 0, end = 0;
            for (start = 0; start < n; start++) {
                if (curH[start] < h[start]) {
                    break;
                }
            }
            if (start >= n) {
                break;
            }
            count++;
            int i;
            for (i = start; i < n; i++) {
                if (curH[i] < h[i]) {
                    curH[i]++;
                } else {
                    break;
                }
            }
        }
        
        System.out.println(count);
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] h = new int[n];
        int[] curH = new int[n];
        
        for (int i = 0; i < n; i++) {
            h[i] = scanner.nextInt();
        }
        int count = 0;
        outer:
        while (true) {
            int start = 0, end = 0;
            for (start = 0; start < n; start++) {
                if (curH[start] < h[start]) {
                    break;
                }
            }
            if (start >= n) {
                break;
            }
            count++;
            int i;
            for (i = start; i < n; i++) {
                if (curH[i] < h[i]) {
                    curH[i]++;
                } else {
                    break;
                }
            }
        }
        
        System.out.println(count);
    }
}
