import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] h = new int[N];
            for (int i = 0; i < N; i++) {
                h[i] = in.nextInt();
            }

            int count = 0;
            A: for (;;) {
                for (int i = 0; i < N; i++) {
                    if (h[i] > 0) {
                        decrease(N, h, i);
                        count++;
                        continue A;
                    }
                }
                break;
            }

            System.out.println(count);
        }
    }

    private static void decrease(int N, int[] h, int i) {
        for (int j = i; j < N; j++) {
            if (h[j] <= 0) {
                break;
            }
            h[j]--;
        }
    }

    private static int f(int n) {
        return n % 2 == 0 ? (n / 2) : (3 * n + 1);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] h = new int[N];
            for (int i = 0; i < N; i++) {
                h[i] = in.nextInt();
            }

            int count = 0;
            A: for (;;) {
                for (int i = 0; i < N; i++) {
                    if (h[i] > 0) {
                        decrease(N, h, i);
                        count++;
                        continue A;
                    }
                }
                break;
            }

            System.out.println(count);
        }
    }

    private static void decrease(int N, int[] h, int i) {
        for (int j = i; j < N; j++) {
            if (h[j] <= 0) {
                break;
            }
            h[j]--;
        }
    }

    private static int f(int n) {
        return n % 2 == 0 ? (n / 2) : (3 * n + 1);
    }
} Main public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] h = new int[N];
            for (int i = 0; i < N; i++) {
                h[i] = in.nextInt();
            }

            int count = 0;
            A: for (;;) {
                for (int i = 0; i < N; i++) {
                    if (h[i] > 0) {
                        decrease(N, h, i);
                        count++;
                        continue A;
                    }
                }
                break;
            }

            System.out.println(count);
        }
    } main {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] h = new int[N];
            for (int i = 0; i < N; i++) {
                h[i] = in.nextInt();
            }

            int count = 0;
            A: for (;;) {
                for (int i = 0; i < N; i++) {
                    if (h[i] > 0) {
                        decrease(N, h, i);
                        count++;
                        continue A;
                    }
                }
                break;
            }

            System.out.println(count);
        }
    } try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] h = new int[N];
            for (int i = 0; i < N; i++) {
                h[i] = in.nextInt();
            }

            int count = 0;
            A: for (;;) {
                for (int i = 0; i < N; i++) {
                    if (h[i] > 0) {
                        decrease(N, h, i);
                        count++;
                        continue A;
                    }
                }
                break;
            }

            System.out.println(count);
        } {
            int N = in.nextInt();
            int[] h = new int[N];
            for (int i = 0; i < N; i++) {
                h[i] = in.nextInt();
            }

            int count = 0;
            A: for (;;) {
                for (int i = 0; i < N; i++) {
                    if (h[i] > 0) {
                        decrease(N, h, i);
                        count++;
                        continue A;
                    }
                }
                break;
            }

            System.out.println(count);
        } Scanner in = new Scanner(System.in) Scanner in = new Scanner(System.in) new Scanner(System.in) int N = in.nextInt(); N in.nextInt() in.nextInt in int[] h = new int[N]; h new int[N] N for (int i = 0; i < N; i++) {
                h[i] = in.nextInt();
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                h[i] = in.nextInt();
            } {
                h[i] = in.nextInt();
            } h[i] = in.nextInt() h[i] h i in.nextInt() in.nextInt in int count = 0; count 0 System.out.println(count) System.out.println System.out System System.out count String args[] args private static void decrease(int N, int[] h, int i) {
        for (int j = i; j < N; j++) {
            if (h[j] <= 0) {
                break;
            }
            h[j]--;
        }
    } decrease {
        for (int j = i; j < N; j++) {
            if (h[j] <= 0) {
                break;
            }
            h[j]--;
        }
    } for (int j = i; j < N; j++) {
            if (h[j] <= 0) {
                break;
            }
            h[j]--;
        } int j = i; int j = i; j i j < N j N j++ j++ j {
            if (h[j] <= 0) {
                break;
            }
            h[j]--;
        } {
            if (h[j] <= 0) {
                break;
            }
            h[j]--;
        } if (h[j] <= 0) {
                break;
            } h[j] <= 0 h[j] h j 0 {
                break;
            } break; h[j]-- h[j] h j int N N int[] h h int i i private static int f(int n) {
        return n % 2 == 0 ? (n / 2) : (3 * n + 1);
    } f {
        return n % 2 == 0 ? (n / 2) : (3 * n + 1);
    } return n % 2 == 0 ? (n / 2) : (3 * n + 1); n % 2 == 0 ? (n / 2) : (3 * n + 1) n % 2 == 0 n % 2 n 2 0 (n / 2) n 2 (3 * n + 1) 3 * n 3 n 1 int n n public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] h = new int[N];
            for (int i = 0; i < N; i++) {
                h[i] = in.nextInt();
            }

            int count = 0;
            A: for (;;) {
                for (int i = 0; i < N; i++) {
                    if (h[i] > 0) {
                        decrease(N, h, i);
                        count++;
                        continue A;
                    }
                }
                break;
            }

            System.out.println(count);
        }
    }

    private static void decrease(int N, int[] h, int i) {
        for (int j = i; j < N; j++) {
            if (h[j] <= 0) {
                break;
            }
            h[j]--;
        }
    }

    private static int f(int n) {
        return n % 2 == 0 ? (n / 2) : (3 * n + 1);
    }
} public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] h = new int[N];
            for (int i = 0; i < N; i++) {
                h[i] = in.nextInt();
            }

            int count = 0;
            A: for (;;) {
                for (int i = 0; i < N; i++) {
                    if (h[i] > 0) {
                        decrease(N, h, i);
                        count++;
                        continue A;
                    }
                }
                break;
            }

            System.out.println(count);
        }
    }

    private static void decrease(int N, int[] h, int i) {
        for (int j = i; j < N; j++) {
            if (h[j] <= 0) {
                break;
            }
            h[j]--;
        }
    }

    private static int f(int n) {
        return n % 2 == 0 ? (n / 2) : (3 * n + 1);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] h = new int[N];
            for (int i = 0; i < N; i++) {
                h[i] = in.nextInt();
            }

            int count = 0;
            A: for (;;) {
                for (int i = 0; i < N; i++) {
                    if (h[i] > 0) {
                        decrease(N, h, i);
                        count++;
                        continue A;
                    }
                }
                break;
            }

            System.out.println(count);
        }
    }

    private static void decrease(int N, int[] h, int i) {
        for (int j = i; j < N; j++) {
            if (h[j] <= 0) {
                break;
            }
            h[j]--;
        }
    }

    private static int f(int n) {
        return n % 2 == 0 ? (n / 2) : (3 * n + 1);
    }
}
