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();
		sc.close();
		int t[] = new int[n];
		
		int max = 0;
		for(int i=0;i<n;i++) max = Math.max(h[i], max);
		
		int cnt = 0;
		for(int i=0;i<max;i++) {

			boolean minus = false;
			for(int j=0;j<n;j++) {
				if(t[j]<h[j]) {
					if(!minus) {
						cnt++;
					}
					minus = true;
					t[j]++;
				}
				else {
					minus = false;
				}
			}
			
		}
		System.out.println(cnt);
		
	}
	

} 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();
		sc.close();
		int t[] = new int[n];
		
		int max = 0;
		for(int i=0;i<n;i++) max = Math.max(h[i], max);
		
		int cnt = 0;
		for(int i=0;i<max;i++) {

			boolean minus = false;
			for(int j=0;j<n;j++) {
				if(t[j]<h[j]) {
					if(!minus) {
						cnt++;
					}
					minus = true;
					t[j]++;
				}
				else {
					minus = false;
				}
			}
			
		}
		System.out.println(cnt);
		
	}
	

} 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();
		sc.close();
		int t[] = new int[n];
		
		int max = 0;
		for(int i=0;i<n;i++) max = Math.max(h[i], max);
		
		int cnt = 0;
		for(int i=0;i<max;i++) {

			boolean minus = false;
			for(int j=0;j<n;j++) {
				if(t[j]<h[j]) {
					if(!minus) {
						cnt++;
					}
					minus = true;
					t[j]++;
				}
				else {
					minus = false;
				}
			}
			
		}
		System.out.println(cnt);
		
	} 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();
		sc.close();
		int t[] = new int[n];
		
		int max = 0;
		for(int i=0;i<n;i++) max = Math.max(h[i], max);
		
		int cnt = 0;
		for(int i=0;i<max;i++) {

			boolean minus = false;
			for(int j=0;j<n;j++) {
				if(t[j]<h[j]) {
					if(!minus) {
						cnt++;
					}
					minus = true;
					t[j]++;
				}
				else {
					minus = false;
				}
			}
			
		}
		System.out.println(cnt);
		
	} 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] h i sc.nextInt() sc.nextInt sc sc.close() sc.close sc int t[] = new int[n]; t new int[n] n int max = 0; max 0 for(int i=0;i<n;i++) max = Math.max(h[i], max); int i=0; int i=0; i 0 i<n i n i++ i++ i max = Math.max(h[i], max); max = Math.max(h[i], max) max Math.max(h[i], max) Math.max Math h[i] h i max int cnt = 0; cnt 0 for(int i=0;i<max;i++) {

			boolean minus = false;
			for(int j=0;j<n;j++) {
				if(t[j]<h[j]) {
					if(!minus) {
						cnt++;
					}
					minus = true;
					t[j]++;
				}
				else {
					minus = false;
				}
			}
			
		} int i=0; int i=0; i 0 i<max i max i++ i++ i {

			boolean minus = false;
			for(int j=0;j<n;j++) {
				if(t[j]<h[j]) {
					if(!minus) {
						cnt++;
					}
					minus = true;
					t[j]++;
				}
				else {
					minus = false;
				}
			}
			
		} {

			boolean minus = false;
			for(int j=0;j<n;j++) {
				if(t[j]<h[j]) {
					if(!minus) {
						cnt++;
					}
					minus = true;
					t[j]++;
				}
				else {
					minus = false;
				}
			}
			
		} boolean minus = false; minus false for(int j=0;j<n;j++) {
				if(t[j]<h[j]) {
					if(!minus) {
						cnt++;
					}
					minus = true;
					t[j]++;
				}
				else {
					minus = false;
				}
			} int j=0; int j=0; j 0 j<n j n j++ j++ j {
				if(t[j]<h[j]) {
					if(!minus) {
						cnt++;
					}
					minus = true;
					t[j]++;
				}
				else {
					minus = false;
				}
			} {
				if(t[j]<h[j]) {
					if(!minus) {
						cnt++;
					}
					minus = true;
					t[j]++;
				}
				else {
					minus = false;
				}
			} if(t[j]<h[j]) {
					if(!minus) {
						cnt++;
					}
					minus = true;
					t[j]++;
				}
				else {
					minus = false;
				} t[j]<h[j] t[j] t j h[j] h j {
					if(!minus) {
						cnt++;
					}
					minus = true;
					t[j]++;
				} if(!minus) {
						cnt++;
					} !minus minus {
						cnt++;
					} cnt++ cnt minus = true minus true t[j]++ t[j] t j {
					minus = false;
				} minus = false minus false System.out.println(cnt) System.out.println System.out System System.out cnt 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();
		sc.close();
		int t[] = new int[n];
		
		int max = 0;
		for(int i=0;i<n;i++) max = Math.max(h[i], max);
		
		int cnt = 0;
		for(int i=0;i<max;i++) {

			boolean minus = false;
			for(int j=0;j<n;j++) {
				if(t[j]<h[j]) {
					if(!minus) {
						cnt++;
					}
					minus = true;
					t[j]++;
				}
				else {
					minus = false;
				}
			}
			
		}
		System.out.println(cnt);
		
	}
	

} 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();
		sc.close();
		int t[] = new int[n];
		
		int max = 0;
		for(int i=0;i<n;i++) max = Math.max(h[i], max);
		
		int cnt = 0;
		for(int i=0;i<max;i++) {

			boolean minus = false;
			for(int j=0;j<n;j++) {
				if(t[j]<h[j]) {
					if(!minus) {
						cnt++;
					}
					minus = true;
					t[j]++;
				}
				else {
					minus = false;
				}
			}
			
		}
		System.out.println(cnt);
		
	}
	

} 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();
		sc.close();
		int t[] = new int[n];
		
		int max = 0;
		for(int i=0;i<n;i++) max = Math.max(h[i], max);
		
		int cnt = 0;
		for(int i=0;i<max;i++) {

			boolean minus = false;
			for(int j=0;j<n;j++) {
				if(t[j]<h[j]) {
					if(!minus) {
						cnt++;
					}
					minus = true;
					t[j]++;
				}
				else {
					minus = false;
				}
			}
			
		}
		System.out.println(cnt);
		
	}
	

}
