import java.util.Scanner;

public class Main {
	public static final int MAX_HIGHT = 100;

	public static int N;
	public static int[] h;

	public static void main(String[] args) {
		readInput();
		
		int water = 0;
		
		for(int hight = 0; hight < MAX_HIGHT; hight++) {
			for(int i = 1; i <= N; i++) {
				if(h[i] > hight && h[i-1] <= hight) {
					water++;
				}
			}
		}
		
		System.out.println(water);
	}

	public static void readInput() {
		try (Scanner sc = new Scanner(System.in)) {
			N = sc.nextInt();

			h = new int[N+1];

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

} import java.util.Scanner; Scanner java.util public class Main {
	public static final int MAX_HIGHT = 100;

	public static int N;
	public static int[] h;

	public static void main(String[] args) {
		readInput();
		
		int water = 0;
		
		for(int hight = 0; hight < MAX_HIGHT; hight++) {
			for(int i = 1; i <= N; i++) {
				if(h[i] > hight && h[i-1] <= hight) {
					water++;
				}
			}
		}
		
		System.out.println(water);
	}

	public static void readInput() {
		try (Scanner sc = new Scanner(System.in)) {
			N = sc.nextInt();

			h = new int[N+1];

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

} Main public static final int MAX_HIGHT = 100; MAX_HIGHT 100 public static int N; N public static int[] h; h public static void main(String[] args) {
		readInput();
		
		int water = 0;
		
		for(int hight = 0; hight < MAX_HIGHT; hight++) {
			for(int i = 1; i <= N; i++) {
				if(h[i] > hight && h[i-1] <= hight) {
					water++;
				}
			}
		}
		
		System.out.println(water);
	} main {
		readInput();
		
		int water = 0;
		
		for(int hight = 0; hight < MAX_HIGHT; hight++) {
			for(int i = 1; i <= N; i++) {
				if(h[i] > hight && h[i-1] <= hight) {
					water++;
				}
			}
		}
		
		System.out.println(water);
	} readInput() readInput int water = 0; water 0 for(int hight = 0; hight < MAX_HIGHT; hight++) {
			for(int i = 1; i <= N; i++) {
				if(h[i] > hight && h[i-1] <= hight) {
					water++;
				}
			}
		} int hight = 0; int hight = 0; hight 0 hight < MAX_HIGHT hight MAX_HIGHT hight++ hight++ hight {
			for(int i = 1; i <= N; i++) {
				if(h[i] > hight && h[i-1] <= hight) {
					water++;
				}
			}
		} {
			for(int i = 1; i <= N; i++) {
				if(h[i] > hight && h[i-1] <= hight) {
					water++;
				}
			}
		} for(int i = 1; i <= N; i++) {
				if(h[i] > hight && h[i-1] <= hight) {
					water++;
				}
			} int i = 1; int i = 1; i 1 i <= N i N i++ i++ i {
				if(h[i] > hight && h[i-1] <= hight) {
					water++;
				}
			} {
				if(h[i] > hight && h[i-1] <= hight) {
					water++;
				}
			} if(h[i] > hight && h[i-1] <= hight) {
					water++;
				} h[i] > hight && h[i-1] <= hight h[i] > hight h[i] h i hight h[i-1] <= hight h[i-1] h i-1 i 1 hight {
					water++;
				} water++ water System.out.println(water) System.out.println System.out System System.out water String[] args args public static void readInput() {
		try (Scanner sc = new Scanner(System.in)) {
			N = sc.nextInt();

			h = new int[N+1];

			for(int i = 1; i <= N; i++) {
				h[i] = sc.nextInt();
			}
		}
	} readInput {
		try (Scanner sc = new Scanner(System.in)) {
			N = sc.nextInt();

			h = new int[N+1];

			for(int i = 1; i <= N; i++) {
				h[i] = sc.nextInt();
			}
		}
	} try (Scanner sc = new Scanner(System.in)) {
			N = sc.nextInt();

			h = new int[N+1];

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

			h = new int[N+1];

			for(int i = 1; i <= N; i++) {
				h[i] = sc.nextInt();
			}
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) N = sc.nextInt() N sc.nextInt() sc.nextInt sc h = new int[N+1] h new int[N+1] N+1 N 1 for(int i = 1; i <= N; i++) {
				h[i] = sc.nextInt();
			} int i = 1; int i = 1; i 1 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 public class Main {
	public static final int MAX_HIGHT = 100;

	public static int N;
	public static int[] h;

	public static void main(String[] args) {
		readInput();
		
		int water = 0;
		
		for(int hight = 0; hight < MAX_HIGHT; hight++) {
			for(int i = 1; i <= N; i++) {
				if(h[i] > hight && h[i-1] <= hight) {
					water++;
				}
			}
		}
		
		System.out.println(water);
	}

	public static void readInput() {
		try (Scanner sc = new Scanner(System.in)) {
			N = sc.nextInt();

			h = new int[N+1];

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

} public class Main {
	public static final int MAX_HIGHT = 100;

	public static int N;
	public static int[] h;

	public static void main(String[] args) {
		readInput();
		
		int water = 0;
		
		for(int hight = 0; hight < MAX_HIGHT; hight++) {
			for(int i = 1; i <= N; i++) {
				if(h[i] > hight && h[i-1] <= hight) {
					water++;
				}
			}
		}
		
		System.out.println(water);
	}

	public static void readInput() {
		try (Scanner sc = new Scanner(System.in)) {
			N = sc.nextInt();

			h = new int[N+1];

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

} Main
import java.util.Scanner;

public class Main {
	public static final int MAX_HIGHT = 100;

	public static int N;
	public static int[] h;

	public static void main(String[] args) {
		readInput();
		
		int water = 0;
		
		for(int hight = 0; hight < MAX_HIGHT; hight++) {
			for(int i = 1; i <= N; i++) {
				if(h[i] > hight && h[i-1] <= hight) {
					water++;
				}
			}
		}
		
		System.out.println(water);
	}

	public static void readInput() {
		try (Scanner sc = new Scanner(System.in)) {
			N = sc.nextInt();

			h = new int[N+1];

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

}
