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];

        for (int i = 0; i < N; i++) {
            h[i] = sc.nextInt();
        }

        boolean mizuyari = true;
        int count = 0;
        int nowh[] = new int[N];
        while (mizuyari) {
            mizuyari = false;
            for (int i = 0; i < N; i++) {
                if (nowh[i] < h[i]) {
                    mizuyari = true;
                    nowh[i] = nowh[i] + 1;
                } else {
                    if (mizuyari) {
                        break;
                    }
                }
            }
            if (mizuyari) {
                count++;
            }
        }

        System.out.println(count);
        sc.close();
    }
} 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];

        for (int i = 0; i < N; i++) {
            h[i] = sc.nextInt();
        }

        boolean mizuyari = true;
        int count = 0;
        int nowh[] = new int[N];
        while (mizuyari) {
            mizuyari = false;
            for (int i = 0; i < N; i++) {
                if (nowh[i] < h[i]) {
                    mizuyari = true;
                    nowh[i] = nowh[i] + 1;
                } else {
                    if (mizuyari) {
                        break;
                    }
                }
            }
            if (mizuyari) {
                count++;
            }
        }

        System.out.println(count);
        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int h[] = new int[N];

        for (int i = 0; i < N; i++) {
            h[i] = sc.nextInt();
        }

        boolean mizuyari = true;
        int count = 0;
        int nowh[] = new int[N];
        while (mizuyari) {
            mizuyari = false;
            for (int i = 0; i < N; i++) {
                if (nowh[i] < h[i]) {
                    mizuyari = true;
                    nowh[i] = nowh[i] + 1;
                } else {
                    if (mizuyari) {
                        break;
                    }
                }
            }
            if (mizuyari) {
                count++;
            }
        }

        System.out.println(count);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int h[] = new int[N];

        for (int i = 0; i < N; i++) {
            h[i] = sc.nextInt();
        }

        boolean mizuyari = true;
        int count = 0;
        int nowh[] = new int[N];
        while (mizuyari) {
            mizuyari = false;
            for (int i = 0; i < N; i++) {
                if (nowh[i] < h[i]) {
                    mizuyari = true;
                    nowh[i] = nowh[i] + 1;
                } else {
                    if (mizuyari) {
                        break;
                    }
                }
            }
            if (mizuyari) {
                count++;
            }
        }

        System.out.println(count);
        sc.close();
    } 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]; h new int[N] N for (int i = 0; i < N; i++) {
            h[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            h[i] = sc.nextInt();
        } {
            h[i] = sc.nextInt();
        } h[i] = sc.nextInt() h[i] h i sc.nextInt() sc.nextInt sc boolean mizuyari = true; mizuyari true int count = 0; count 0 int nowh[] = new int[N]; nowh new int[N] N while (mizuyari) {
            mizuyari = false;
            for (int i = 0; i < N; i++) {
                if (nowh[i] < h[i]) {
                    mizuyari = true;
                    nowh[i] = nowh[i] + 1;
                } else {
                    if (mizuyari) {
                        break;
                    }
                }
            }
            if (mizuyari) {
                count++;
            }
        } mizuyari {
            mizuyari = false;
            for (int i = 0; i < N; i++) {
                if (nowh[i] < h[i]) {
                    mizuyari = true;
                    nowh[i] = nowh[i] + 1;
                } else {
                    if (mizuyari) {
                        break;
                    }
                }
            }
            if (mizuyari) {
                count++;
            }
        } mizuyari = false mizuyari false for (int i = 0; i < N; i++) {
                if (nowh[i] < h[i]) {
                    mizuyari = true;
                    nowh[i] = nowh[i] + 1;
                } else {
                    if (mizuyari) {
                        break;
                    }
                }
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                if (nowh[i] < h[i]) {
                    mizuyari = true;
                    nowh[i] = nowh[i] + 1;
                } else {
                    if (mizuyari) {
                        break;
                    }
                }
            } {
                if (nowh[i] < h[i]) {
                    mizuyari = true;
                    nowh[i] = nowh[i] + 1;
                } else {
                    if (mizuyari) {
                        break;
                    }
                }
            } if (nowh[i] < h[i]) {
                    mizuyari = true;
                    nowh[i] = nowh[i] + 1;
                } else {
                    if (mizuyari) {
                        break;
                    }
                } nowh[i] < h[i] nowh[i] nowh i h[i] h i {
                    mizuyari = true;
                    nowh[i] = nowh[i] + 1;
                } mizuyari = true mizuyari true nowh[i] = nowh[i] + 1 nowh[i] nowh i nowh[i] + 1 nowh[i] nowh i 1 {
                    if (mizuyari) {
                        break;
                    }
                } if (mizuyari) {
                        break;
                    } mizuyari {
                        break;
                    } break; if (mizuyari) {
                count++;
            } mizuyari {
                count++;
            } count++ count System.out.println(count) System.out.println System.out System System.out count sc.close() sc.close sc 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];

        for (int i = 0; i < N; i++) {
            h[i] = sc.nextInt();
        }

        boolean mizuyari = true;
        int count = 0;
        int nowh[] = new int[N];
        while (mizuyari) {
            mizuyari = false;
            for (int i = 0; i < N; i++) {
                if (nowh[i] < h[i]) {
                    mizuyari = true;
                    nowh[i] = nowh[i] + 1;
                } else {
                    if (mizuyari) {
                        break;
                    }
                }
            }
            if (mizuyari) {
                count++;
            }
        }

        System.out.println(count);
        sc.close();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int h[] = new int[N];

        for (int i = 0; i < N; i++) {
            h[i] = sc.nextInt();
        }

        boolean mizuyari = true;
        int count = 0;
        int nowh[] = new int[N];
        while (mizuyari) {
            mizuyari = false;
            for (int i = 0; i < N; i++) {
                if (nowh[i] < h[i]) {
                    mizuyari = true;
                    nowh[i] = nowh[i] + 1;
                } else {
                    if (mizuyari) {
                        break;
                    }
                }
            }
            if (mizuyari) {
                count++;
            }
        }

        System.out.println(count);
        sc.close();
    }
} 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];

        for (int i = 0; i < N; i++) {
            h[i] = sc.nextInt();
        }

        boolean mizuyari = true;
        int count = 0;
        int nowh[] = new int[N];
        while (mizuyari) {
            mizuyari = false;
            for (int i = 0; i < N; i++) {
                if (nowh[i] < h[i]) {
                    mizuyari = true;
                    nowh[i] = nowh[i] + 1;
                } else {
                    if (mizuyari) {
                        break;
                    }
                }
            }
            if (mizuyari) {
                count++;
            }
        }

        System.out.println(count);
        sc.close();
    }
}