import java.util.*;
public class Main {

	static int flower[] = new int[100];
	static int flower_h[] = new int[100];
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int count = 0;
		
		for(int i = 0; i < num; i++) {
			flower_h[i] = sc.nextInt();
		}
		
		if(num == 1) {
			System.out.println(flower_h[0]);
			return;
		}
	
		while(!isHeight(num)) {
			for(int i = 0; i < num; i++) {
				
				//現在の花の高さが既に同じの場合はスキップ
				if(flower_h[i] == flower[i]) { 
					continue;
				}
				
				//水やり
				flower[i]++;
				
				//右端の場合はbreak
				if(i == num -1 ) {
					break;
				}
				
				//右隣の高さが同じの場合はbreak;
				if(flower_h[i+1] == flower[i+1]) {
					break;
				}
			}
			count++;
		}
		
		System.out.println(count);

	}
	
	public static boolean isHeight(int len) {
		
		for(int i = 0; i < len; i++) {
			if(flower_h[i] != flower[i]) {
				return false;
			}
		}
		return true;
	}
}
 import java.util.*; util.* java public class Main {

	static int flower[] = new int[100];
	static int flower_h[] = new int[100];
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int count = 0;
		
		for(int i = 0; i < num; i++) {
			flower_h[i] = sc.nextInt();
		}
		
		if(num == 1) {
			System.out.println(flower_h[0]);
			return;
		}
	
		while(!isHeight(num)) {
			for(int i = 0; i < num; i++) {
				
				//現在の花の高さが既に同じの場合はスキップ
				if(flower_h[i] == flower[i]) { 
					continue;
				}
				
				//水やり
				flower[i]++;
				
				//右端の場合はbreak
				if(i == num -1 ) {
					break;
				}
				
				//右隣の高さが同じの場合はbreak;
				if(flower_h[i+1] == flower[i+1]) {
					break;
				}
			}
			count++;
		}
		
		System.out.println(count);

	}
	
	public static boolean isHeight(int len) {
		
		for(int i = 0; i < len; i++) {
			if(flower_h[i] != flower[i]) {
				return false;
			}
		}
		return true;
	}
} Main static int flower[] = new int[100]; flower new int[100] 100 static int flower_h[] = new int[100]; flower_h new int[100] 100 public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int count = 0;
		
		for(int i = 0; i < num; i++) {
			flower_h[i] = sc.nextInt();
		}
		
		if(num == 1) {
			System.out.println(flower_h[0]);
			return;
		}
	
		while(!isHeight(num)) {
			for(int i = 0; i < num; i++) {
				
				//現在の花の高さが既に同じの場合はスキップ
				if(flower_h[i] == flower[i]) { 
					continue;
				}
				
				//水やり
				flower[i]++;
				
				//右端の場合はbreak
				if(i == num -1 ) {
					break;
				}
				
				//右隣の高さが同じの場合はbreak;
				if(flower_h[i+1] == flower[i+1]) {
					break;
				}
			}
			count++;
		}
		
		System.out.println(count);

	} main {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int count = 0;
		
		for(int i = 0; i < num; i++) {
			flower_h[i] = sc.nextInt();
		}
		
		if(num == 1) {
			System.out.println(flower_h[0]);
			return;
		}
	
		while(!isHeight(num)) {
			for(int i = 0; i < num; i++) {
				
				//現在の花の高さが既に同じの場合はスキップ
				if(flower_h[i] == flower[i]) { 
					continue;
				}
				
				//水やり
				flower[i]++;
				
				//右端の場合はbreak
				if(i == num -1 ) {
					break;
				}
				
				//右隣の高さが同じの場合はbreak;
				if(flower_h[i+1] == flower[i+1]) {
					break;
				}
			}
			count++;
		}
		
		System.out.println(count);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc int count = 0; count 0 for(int i = 0; i < num; i++) {
			flower_h[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
			flower_h[i] = sc.nextInt();
		} {
			flower_h[i] = sc.nextInt();
		} flower_h[i] = sc.nextInt() flower_h[i] flower_h i sc.nextInt() sc.nextInt sc if(num == 1) {
			System.out.println(flower_h[0]);
			return;
		} num == 1 num 1 {
			System.out.println(flower_h[0]);
			return;
		} System.out.println(flower_h[0]) System.out.println System.out System System.out flower_h[0] flower_h 0 return; while(!isHeight(num)) {
			for(int i = 0; i < num; i++) {
				
				//現在の花の高さが既に同じの場合はスキップ
				if(flower_h[i] == flower[i]) { 
					continue;
				}
				
				//水やり
				flower[i]++;
				
				//右端の場合はbreak
				if(i == num -1 ) {
					break;
				}
				
				//右隣の高さが同じの場合はbreak;
				if(flower_h[i+1] == flower[i+1]) {
					break;
				}
			}
			count++;
		} !isHeight(num) isHeight(num) isHeight num {
			for(int i = 0; i < num; i++) {
				
				//現在の花の高さが既に同じの場合はスキップ
				if(flower_h[i] == flower[i]) { 
					continue;
				}
				
				//水やり
				flower[i]++;
				
				//右端の場合はbreak
				if(i == num -1 ) {
					break;
				}
				
				//右隣の高さが同じの場合はbreak;
				if(flower_h[i+1] == flower[i+1]) {
					break;
				}
			}
			count++;
		} for(int i = 0; i < num; i++) {
				
				//現在の花の高さが既に同じの場合はスキップ
				if(flower_h[i] == flower[i]) { 
					continue;
				}
				
				//水やり
				flower[i]++;
				
				//右端の場合はbreak
				if(i == num -1 ) {
					break;
				}
				
				//右隣の高さが同じの場合はbreak;
				if(flower_h[i+1] == flower[i+1]) {
					break;
				}
			} int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
				
				//現在の花の高さが既に同じの場合はスキップ
				if(flower_h[i] == flower[i]) { 
					continue;
				}
				
				//水やり
				flower[i]++;
				
				//右端の場合はbreak
				if(i == num -1 ) {
					break;
				}
				
				//右隣の高さが同じの場合はbreak;
				if(flower_h[i+1] == flower[i+1]) {
					break;
				}
			} {
				
				//現在の花の高さが既に同じの場合はスキップ
				if(flower_h[i] == flower[i]) { 
					continue;
				}
				
				//水やり
				flower[i]++;
				
				//右端の場合はbreak
				if(i == num -1 ) {
					break;
				}
				
				//右隣の高さが同じの場合はbreak;
				if(flower_h[i+1] == flower[i+1]) {
					break;
				}
			} if(flower_h[i] == flower[i]) { 
					continue;
				} flower_h[i] == flower[i] flower_h[i] flower_h i flower[i] flower i { 
					continue;
				} continue; flower[i]++ flower[i] flower i if(i == num -1 ) {
					break;
				} i == num -1 i num -1 num 1 {
					break;
				} break; if(flower_h[i+1] == flower[i+1]) {
					break;
				} flower_h[i+1] == flower[i+1] flower_h[i+1] flower_h i+1 i 1 flower[i+1] flower i+1 i 1 {
					break;
				} break; count++ count System.out.println(count) System.out.println System.out System System.out count String args[] args public static boolean isHeight(int len) {
		
		for(int i = 0; i < len; i++) {
			if(flower_h[i] != flower[i]) {
				return false;
			}
		}
		return true;
	} isHeight {
		
		for(int i = 0; i < len; i++) {
			if(flower_h[i] != flower[i]) {
				return false;
			}
		}
		return true;
	} for(int i = 0; i < len; i++) {
			if(flower_h[i] != flower[i]) {
				return false;
			}
		} int i = 0; int i = 0; i 0 i < len i len i++ i++ i {
			if(flower_h[i] != flower[i]) {
				return false;
			}
		} {
			if(flower_h[i] != flower[i]) {
				return false;
			}
		} if(flower_h[i] != flower[i]) {
				return false;
			} flower_h[i] != flower[i] flower_h[i] flower_h i flower[i] flower i {
				return false;
			} return false; false return true; true int len len public class Main {

	static int flower[] = new int[100];
	static int flower_h[] = new int[100];
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int count = 0;
		
		for(int i = 0; i < num; i++) {
			flower_h[i] = sc.nextInt();
		}
		
		if(num == 1) {
			System.out.println(flower_h[0]);
			return;
		}
	
		while(!isHeight(num)) {
			for(int i = 0; i < num; i++) {
				
				//現在の花の高さが既に同じの場合はスキップ
				if(flower_h[i] == flower[i]) { 
					continue;
				}
				
				//水やり
				flower[i]++;
				
				//右端の場合はbreak
				if(i == num -1 ) {
					break;
				}
				
				//右隣の高さが同じの場合はbreak;
				if(flower_h[i+1] == flower[i+1]) {
					break;
				}
			}
			count++;
		}
		
		System.out.println(count);

	}
	
	public static boolean isHeight(int len) {
		
		for(int i = 0; i < len; i++) {
			if(flower_h[i] != flower[i]) {
				return false;
			}
		}
		return true;
	}
} public class Main {

	static int flower[] = new int[100];
	static int flower_h[] = new int[100];
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int count = 0;
		
		for(int i = 0; i < num; i++) {
			flower_h[i] = sc.nextInt();
		}
		
		if(num == 1) {
			System.out.println(flower_h[0]);
			return;
		}
	
		while(!isHeight(num)) {
			for(int i = 0; i < num; i++) {
				
				//現在の花の高さが既に同じの場合はスキップ
				if(flower_h[i] == flower[i]) { 
					continue;
				}
				
				//水やり
				flower[i]++;
				
				//右端の場合はbreak
				if(i == num -1 ) {
					break;
				}
				
				//右隣の高さが同じの場合はbreak;
				if(flower_h[i+1] == flower[i+1]) {
					break;
				}
			}
			count++;
		}
		
		System.out.println(count);

	}
	
	public static boolean isHeight(int len) {
		
		for(int i = 0; i < len; i++) {
			if(flower_h[i] != flower[i]) {
				return false;
			}
		}
		return true;
	}
} Main
import java.util.*;
public class Main {

	static int flower[] = new int[100];
	static int flower_h[] = new int[100];
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int count = 0;
		
		for(int i = 0; i < num; i++) {
			flower_h[i] = sc.nextInt();
		}
		
		if(num == 1) {
			System.out.println(flower_h[0]);
			return;
		}
	
		while(!isHeight(num)) {
			for(int i = 0; i < num; i++) {
				
				//現在の花の高さが既に同じの場合はスキップ
				if(flower_h[i] == flower[i]) { 
					continue;
				}
				
				//水やり
				flower[i]++;
				
				//右端の場合はbreak
				if(i == num -1 ) {
					break;
				}
				
				//右隣の高さが同じの場合はbreak;
				if(flower_h[i+1] == flower[i+1]) {
					break;
				}
			}
			count++;
		}
		
		System.out.println(count);

	}
	
	public static boolean isHeight(int len) {
		
		for(int i = 0; i < len; i++) {
			if(flower_h[i] != flower[i]) {
				return false;
			}
		}
		return true;
	}
}

