import java.util.Scanner;

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

        int op = 0;
        for (int i = 0; i < n; i++) {
            while (0 < arr[i]) {
                arr[i]--;
                op++;
                for (int s = i+1; s < n; s++) {
                    if (arr[s] != 0) {
                        arr[s]--;
                    } else {
                        break;
                    }
                }
            }
        }
        System.out.println(op);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        int op = 0;
        for (int i = 0; i < n; i++) {
            while (0 < arr[i]) {
                arr[i]--;
                op++;
                for (int s = i+1; s < n; s++) {
                    if (arr[s] != 0) {
                        arr[s]--;
                    } else {
                        break;
                    }
                }
            }
        }
        System.out.println(op);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        int op = 0;
        for (int i = 0; i < n; i++) {
            while (0 < arr[i]) {
                arr[i]--;
                op++;
                for (int s = i+1; s < n; s++) {
                    if (arr[s] != 0) {
                        arr[s]--;
                    } else {
                        break;
                    }
                }
            }
        }
        System.out.println(op);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        int op = 0;
        for (int i = 0; i < n; i++) {
            while (0 < arr[i]) {
                arr[i]--;
                op++;
                for (int s = i+1; s < n; s++) {
                    if (arr[s] != 0) {
                        arr[s]--;
                    } else {
                        break;
                    }
                }
            }
        }
        System.out.println(op);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] arr = new int[n]; arr new int[n] n for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            arr[i] = sc.nextInt();
        } {
            arr[i] = sc.nextInt();
        } arr[i] = sc.nextInt() arr[i] arr i sc.nextInt() sc.nextInt sc int op = 0; op 0 for (int i = 0; i < n; i++) {
            while (0 < arr[i]) {
                arr[i]--;
                op++;
                for (int s = i+1; s < n; s++) {
                    if (arr[s] != 0) {
                        arr[s]--;
                    } else {
                        break;
                    }
                }
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            while (0 < arr[i]) {
                arr[i]--;
                op++;
                for (int s = i+1; s < n; s++) {
                    if (arr[s] != 0) {
                        arr[s]--;
                    } else {
                        break;
                    }
                }
            }
        } {
            while (0 < arr[i]) {
                arr[i]--;
                op++;
                for (int s = i+1; s < n; s++) {
                    if (arr[s] != 0) {
                        arr[s]--;
                    } else {
                        break;
                    }
                }
            }
        } while (0 < arr[i]) {
                arr[i]--;
                op++;
                for (int s = i+1; s < n; s++) {
                    if (arr[s] != 0) {
                        arr[s]--;
                    } else {
                        break;
                    }
                }
            } 0 < arr[i] 0 arr[i] arr i {
                arr[i]--;
                op++;
                for (int s = i+1; s < n; s++) {
                    if (arr[s] != 0) {
                        arr[s]--;
                    } else {
                        break;
                    }
                }
            } arr[i]-- arr[i] arr i op++ op for (int s = i+1; s < n; s++) {
                    if (arr[s] != 0) {
                        arr[s]--;
                    } else {
                        break;
                    }
                } int s = i+1; int s = i+1; s i+1 i 1 s < n s n s++ s++ s {
                    if (arr[s] != 0) {
                        arr[s]--;
                    } else {
                        break;
                    }
                } {
                    if (arr[s] != 0) {
                        arr[s]--;
                    } else {
                        break;
                    }
                } if (arr[s] != 0) {
                        arr[s]--;
                    } else {
                        break;
                    } arr[s] != 0 arr[s] arr s 0 {
                        arr[s]--;
                    } arr[s]-- arr[s] arr s {
                        break;
                    } break; System.out.println(op) System.out.println System.out System System.out op String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        int op = 0;
        for (int i = 0; i < n; i++) {
            while (0 < arr[i]) {
                arr[i]--;
                op++;
                for (int s = i+1; s < n; s++) {
                    if (arr[s] != 0) {
                        arr[s]--;
                    } else {
                        break;
                    }
                }
            }
        }
        System.out.println(op);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        int op = 0;
        for (int i = 0; i < n; i++) {
            while (0 < arr[i]) {
                arr[i]--;
                op++;
                for (int s = i+1; s < n; s++) {
                    if (arr[s] != 0) {
                        arr[s]--;
                    } else {
                        break;
                    }
                }
            }
        }
        System.out.println(op);
    }
} Main
import java.util.Scanner;

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

        int op = 0;
        for (int i = 0; i < n; i++) {
            while (0 < arr[i]) {
                arr[i]--;
                op++;
                for (int s = i+1; s < n; s++) {
                    if (arr[s] != 0) {
                        arr[s]--;
                    } else {
                        break;
                    }
                }
            }
        }
        System.out.println(op);
    }
}