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();
	}

	int ans = 0;
	boolean lastWatered;
	for(int level = 100; level > 0; level--){
	    lastWatered = false;
	    for(int i = 0; i < n; i++){
		if(h[i] == level){
		    h[i]--;
		    if(lastWatered){
			// do nothing
		    }else{
			ans++;
			lastWatered = true;
		    }
		}else{
		    lastWatered = false;
		}
	    }
	}

	System.out.println(ans);
    }

}

 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();
	}

	int ans = 0;
	boolean lastWatered;
	for(int level = 100; level > 0; level--){
	    lastWatered = false;
	    for(int i = 0; i < n; i++){
		if(h[i] == level){
		    h[i]--;
		    if(lastWatered){
			// do nothing
		    }else{
			ans++;
			lastWatered = true;
		    }
		}else{
		    lastWatered = false;
		}
	    }
	}

	System.out.println(ans);
    }

} 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();
	}

	int ans = 0;
	boolean lastWatered;
	for(int level = 100; level > 0; level--){
	    lastWatered = false;
	    for(int i = 0; i < n; i++){
		if(h[i] == level){
		    h[i]--;
		    if(lastWatered){
			// do nothing
		    }else{
			ans++;
			lastWatered = true;
		    }
		}else{
		    lastWatered = false;
		}
	    }
	}

	System.out.println(ans);
    } 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();
	}

	int ans = 0;
	boolean lastWatered;
	for(int level = 100; level > 0; level--){
	    lastWatered = false;
	    for(int i = 0; i < n; i++){
		if(h[i] == level){
		    h[i]--;
		    if(lastWatered){
			// do nothing
		    }else{
			ans++;
			lastWatered = true;
		    }
		}else{
		    lastWatered = false;
		}
	    }
	}

	System.out.println(ans);
    } 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 int ans = 0; ans 0 boolean lastWatered; lastWatered for(int level = 100; level > 0; level--){
	    lastWatered = false;
	    for(int i = 0; i < n; i++){
		if(h[i] == level){
		    h[i]--;
		    if(lastWatered){
			// do nothing
		    }else{
			ans++;
			lastWatered = true;
		    }
		}else{
		    lastWatered = false;
		}
	    }
	} int level = 100; int level = 100; level 100 level > 0 level 0 level-- level-- level {
	    lastWatered = false;
	    for(int i = 0; i < n; i++){
		if(h[i] == level){
		    h[i]--;
		    if(lastWatered){
			// do nothing
		    }else{
			ans++;
			lastWatered = true;
		    }
		}else{
		    lastWatered = false;
		}
	    }
	} {
	    lastWatered = false;
	    for(int i = 0; i < n; i++){
		if(h[i] == level){
		    h[i]--;
		    if(lastWatered){
			// do nothing
		    }else{
			ans++;
			lastWatered = true;
		    }
		}else{
		    lastWatered = false;
		}
	    }
	} lastWatered = false lastWatered false for(int i = 0; i < n; i++){
		if(h[i] == level){
		    h[i]--;
		    if(lastWatered){
			// do nothing
		    }else{
			ans++;
			lastWatered = true;
		    }
		}else{
		    lastWatered = false;
		}
	    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
		if(h[i] == level){
		    h[i]--;
		    if(lastWatered){
			// do nothing
		    }else{
			ans++;
			lastWatered = true;
		    }
		}else{
		    lastWatered = false;
		}
	    } {
		if(h[i] == level){
		    h[i]--;
		    if(lastWatered){
			// do nothing
		    }else{
			ans++;
			lastWatered = true;
		    }
		}else{
		    lastWatered = false;
		}
	    } if(h[i] == level){
		    h[i]--;
		    if(lastWatered){
			// do nothing
		    }else{
			ans++;
			lastWatered = true;
		    }
		}else{
		    lastWatered = false;
		} h[i] == level h[i] h i level {
		    h[i]--;
		    if(lastWatered){
			// do nothing
		    }else{
			ans++;
			lastWatered = true;
		    }
		} h[i]-- h[i] h i if(lastWatered){
			// do nothing
		    }else{
			ans++;
			lastWatered = true;
		    } lastWatered {
			// do nothing
		    } {
			ans++;
			lastWatered = true;
		    } ans++ ans lastWatered = true lastWatered true {
		    lastWatered = false;
		} lastWatered = false lastWatered false 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 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();
	}

	int ans = 0;
	boolean lastWatered;
	for(int level = 100; level > 0; level--){
	    lastWatered = false;
	    for(int i = 0; i < n; i++){
		if(h[i] == level){
		    h[i]--;
		    if(lastWatered){
			// do nothing
		    }else{
			ans++;
			lastWatered = true;
		    }
		}else{
		    lastWatered = false;
		}
	    }
	}

	System.out.println(ans);
    }

} 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();
	}

	int ans = 0;
	boolean lastWatered;
	for(int level = 100; level > 0; level--){
	    lastWatered = false;
	    for(int i = 0; i < n; i++){
		if(h[i] == level){
		    h[i]--;
		    if(lastWatered){
			// do nothing
		    }else{
			ans++;
			lastWatered = true;
		    }
		}else{
		    lastWatered = false;
		}
	    }
	}

	System.out.println(ans);
    }

} 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();
	}

	int ans = 0;
	boolean lastWatered;
	for(int level = 100; level > 0; level--){
	    lastWatered = false;
	    for(int i = 0; i < n; i++){
		if(h[i] == level){
		    h[i]--;
		    if(lastWatered){
			// do nothing
		    }else{
			ans++;
			lastWatered = true;
		    }
		}else{
		    lastWatered = false;
		}
	    }
	}

	System.out.println(ans);
    }

}


