import java.util.*;




public class Main {


    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int[] a = new int[n+1];
        a[0] = 0;
        for (int i = 1; i <= n; i++) {
            a[i] = cin.nextInt();
        }
        int ans = 0;
        for (int i = 1; i <= 111; i++) {
            for (int j = 1; j <= n; j++) {
                if (a[j - 1] == 0 && a[j] > 0) {
                    ans++;
                }
            }
            for (int j = 1; j <= n; j++) {
                if (a[j]>0) {
                    a[j]--;
                }
            }
        }

        System.out.println(ans);
    }


} import java.util.*; util.* java public class Main {


    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int[] a = new int[n+1];
        a[0] = 0;
        for (int i = 1; i <= n; i++) {
            a[i] = cin.nextInt();
        }
        int ans = 0;
        for (int i = 1; i <= 111; i++) {
            for (int j = 1; j <= n; j++) {
                if (a[j - 1] == 0 && a[j] > 0) {
                    ans++;
                }
            }
            for (int j = 1; j <= n; j++) {
                if (a[j]>0) {
                    a[j]--;
                }
            }
        }

        System.out.println(ans);
    }


} Main public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int[] a = new int[n+1];
        a[0] = 0;
        for (int i = 1; i <= n; i++) {
            a[i] = cin.nextInt();
        }
        int ans = 0;
        for (int i = 1; i <= 111; i++) {
            for (int j = 1; j <= n; j++) {
                if (a[j - 1] == 0 && a[j] > 0) {
                    ans++;
                }
            }
            for (int j = 1; j <= n; j++) {
                if (a[j]>0) {
                    a[j]--;
                }
            }
        }

        System.out.println(ans);
    } main {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int[] a = new int[n+1];
        a[0] = 0;
        for (int i = 1; i <= n; i++) {
            a[i] = cin.nextInt();
        }
        int ans = 0;
        for (int i = 1; i <= 111; i++) {
            for (int j = 1; j <= n; j++) {
                if (a[j - 1] == 0 && a[j] > 0) {
                    ans++;
                }
            }
            for (int j = 1; j <= n; j++) {
                if (a[j]>0) {
                    a[j]--;
                }
            }
        }

        System.out.println(ans);
    } Scanner cin = new Scanner(System.in); cin new Scanner(System.in) int n = cin.nextInt(); n cin.nextInt() cin.nextInt cin int[] a = new int[n+1]; a new int[n+1] n+1 n 1 a[0] = 0 a[0] a 0 0 for (int i = 1; i <= n; i++) {
            a[i] = cin.nextInt();
        } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
            a[i] = cin.nextInt();
        } {
            a[i] = cin.nextInt();
        } a[i] = cin.nextInt() a[i] a i cin.nextInt() cin.nextInt cin int ans = 0; ans 0 for (int i = 1; i <= 111; i++) {
            for (int j = 1; j <= n; j++) {
                if (a[j - 1] == 0 && a[j] > 0) {
                    ans++;
                }
            }
            for (int j = 1; j <= n; j++) {
                if (a[j]>0) {
                    a[j]--;
                }
            }
        } int i = 1; int i = 1; i 1 i <= 111 i 111 i++ i++ i {
            for (int j = 1; j <= n; j++) {
                if (a[j - 1] == 0 && a[j] > 0) {
                    ans++;
                }
            }
            for (int j = 1; j <= n; j++) {
                if (a[j]>0) {
                    a[j]--;
                }
            }
        } {
            for (int j = 1; j <= n; j++) {
                if (a[j - 1] == 0 && a[j] > 0) {
                    ans++;
                }
            }
            for (int j = 1; j <= n; j++) {
                if (a[j]>0) {
                    a[j]--;
                }
            }
        } for (int j = 1; j <= n; j++) {
                if (a[j - 1] == 0 && a[j] > 0) {
                    ans++;
                }
            } int j = 1; int j = 1; j 1 j <= n j n j++ j++ j {
                if (a[j - 1] == 0 && a[j] > 0) {
                    ans++;
                }
            } {
                if (a[j - 1] == 0 && a[j] > 0) {
                    ans++;
                }
            } if (a[j - 1] == 0 && a[j] > 0) {
                    ans++;
                } a[j - 1] == 0 && a[j] > 0 a[j - 1] == 0 a[j - 1] a j - 1 j 1 0 a[j] > 0 a[j] a j 0 {
                    ans++;
                } ans++ ans for (int j = 1; j <= n; j++) {
                if (a[j]>0) {
                    a[j]--;
                }
            } int j = 1; int j = 1; j 1 j <= n j n j++ j++ j {
                if (a[j]>0) {
                    a[j]--;
                }
            } {
                if (a[j]>0) {
                    a[j]--;
                }
            } if (a[j]>0) {
                    a[j]--;
                } a[j]>0 a[j] a j 0 {
                    a[j]--;
                } a[j]-- a[j] a j System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {


    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int[] a = new int[n+1];
        a[0] = 0;
        for (int i = 1; i <= n; i++) {
            a[i] = cin.nextInt();
        }
        int ans = 0;
        for (int i = 1; i <= 111; i++) {
            for (int j = 1; j <= n; j++) {
                if (a[j - 1] == 0 && a[j] > 0) {
                    ans++;
                }
            }
            for (int j = 1; j <= n; j++) {
                if (a[j]>0) {
                    a[j]--;
                }
            }
        }

        System.out.println(ans);
    }


} public class Main {


    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int[] a = new int[n+1];
        a[0] = 0;
        for (int i = 1; i <= n; i++) {
            a[i] = cin.nextInt();
        }
        int ans = 0;
        for (int i = 1; i <= 111; i++) {
            for (int j = 1; j <= n; j++) {
                if (a[j - 1] == 0 && a[j] > 0) {
                    ans++;
                }
            }
            for (int j = 1; j <= n; j++) {
                if (a[j]>0) {
                    a[j]--;
                }
            }
        }

        System.out.println(ans);
    }


} Main
import java.util.*;




public class Main {


    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int[] a = new int[n+1];
        a[0] = 0;
        for (int i = 1; i <= n; i++) {
            a[i] = cin.nextInt();
        }
        int ans = 0;
        for (int i = 1; i <= 111; i++) {
            for (int j = 1; j <= n; j++) {
                if (a[j - 1] == 0 && a[j] > 0) {
                    ans++;
                }
            }
            for (int j = 1; j <= n; j++) {
                if (a[j]>0) {
                    a[j]--;
                }
            }
        }

        System.out.println(ans);
    }


}
