import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[] g = new int[a];
		int min=101;
		int max=0;
		int ans = 0;
		for(int i = 0; i<a; i++){
			int b = sc.nextInt();
			g[i]=b;
			if(b<min){
				min=b;
			}
			if(b>max){
				max=b;
			}
		}
		ans+=min;
		while(min<max){
		for(int i = 0; i <a; i++){
			if(g[i]>min){
				if(i==0){
					ans++;
				}else{
				if(g[i-1]>min){
					
				}else{
					ans++;
				}
				}
			}
		}
			min++;
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[] g = new int[a];
		int min=101;
		int max=0;
		int ans = 0;
		for(int i = 0; i<a; i++){
			int b = sc.nextInt();
			g[i]=b;
			if(b<min){
				min=b;
			}
			if(b>max){
				max=b;
			}
		}
		ans+=min;
		while(min<max){
		for(int i = 0; i <a; i++){
			if(g[i]>min){
				if(i==0){
					ans++;
				}else{
				if(g[i-1]>min){
					
				}else{
					ans++;
				}
				}
			}
		}
			min++;
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[] g = new int[a];
		int min=101;
		int max=0;
		int ans = 0;
		for(int i = 0; i<a; i++){
			int b = sc.nextInt();
			g[i]=b;
			if(b<min){
				min=b;
			}
			if(b>max){
				max=b;
			}
		}
		ans+=min;
		while(min<max){
		for(int i = 0; i <a; i++){
			if(g[i]>min){
				if(i==0){
					ans++;
				}else{
				if(g[i-1]>min){
					
				}else{
					ans++;
				}
				}
			}
		}
			min++;
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[] g = new int[a];
		int min=101;
		int max=0;
		int ans = 0;
		for(int i = 0; i<a; i++){
			int b = sc.nextInt();
			g[i]=b;
			if(b<min){
				min=b;
			}
			if(b>max){
				max=b;
			}
		}
		ans+=min;
		while(min<max){
		for(int i = 0; i <a; i++){
			if(g[i]>min){
				if(i==0){
					ans++;
				}else{
				if(g[i-1]>min){
					
				}else{
					ans++;
				}
				}
			}
		}
			min++;
		}
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int[] g = new int[a]; g new int[a] a int min=101; min 101 int max=0; max 0 int ans = 0; ans 0 for(int i = 0; i<a; i++){
			int b = sc.nextInt();
			g[i]=b;
			if(b<min){
				min=b;
			}
			if(b>max){
				max=b;
			}
		} int i = 0; int i = 0; i 0 i<a i a i++ i++ i {
			int b = sc.nextInt();
			g[i]=b;
			if(b<min){
				min=b;
			}
			if(b>max){
				max=b;
			}
		} {
			int b = sc.nextInt();
			g[i]=b;
			if(b<min){
				min=b;
			}
			if(b>max){
				max=b;
			}
		} int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc g[i]=b g[i] g i b if(b<min){
				min=b;
			} b<min b min {
				min=b;
			} min=b min b if(b>max){
				max=b;
			} b>max b max {
				max=b;
			} max=b max b ans+=min ans min while(min<max){
		for(int i = 0; i <a; i++){
			if(g[i]>min){
				if(i==0){
					ans++;
				}else{
				if(g[i-1]>min){
					
				}else{
					ans++;
				}
				}
			}
		}
			min++;
		} min<max min max {
		for(int i = 0; i <a; i++){
			if(g[i]>min){
				if(i==0){
					ans++;
				}else{
				if(g[i-1]>min){
					
				}else{
					ans++;
				}
				}
			}
		}
			min++;
		} for(int i = 0; i <a; i++){
			if(g[i]>min){
				if(i==0){
					ans++;
				}else{
				if(g[i-1]>min){
					
				}else{
					ans++;
				}
				}
			}
		} int i = 0; int i = 0; i 0 i <a i a i++ i++ i {
			if(g[i]>min){
				if(i==0){
					ans++;
				}else{
				if(g[i-1]>min){
					
				}else{
					ans++;
				}
				}
			}
		} {
			if(g[i]>min){
				if(i==0){
					ans++;
				}else{
				if(g[i-1]>min){
					
				}else{
					ans++;
				}
				}
			}
		} if(g[i]>min){
				if(i==0){
					ans++;
				}else{
				if(g[i-1]>min){
					
				}else{
					ans++;
				}
				}
			} g[i]>min g[i] g i min {
				if(i==0){
					ans++;
				}else{
				if(g[i-1]>min){
					
				}else{
					ans++;
				}
				}
			} if(i==0){
					ans++;
				}else{
				if(g[i-1]>min){
					
				}else{
					ans++;
				}
				} i==0 i 0 {
					ans++;
				} ans++ ans {
				if(g[i-1]>min){
					
				}else{
					ans++;
				}
				} if(g[i-1]>min){
					
				}else{
					ans++;
				} g[i-1]>min g[i-1] g i-1 i 1 min {
					
				} {
					ans++;
				} ans++ ans min++ min 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 a = sc.nextInt();
		int[] g = new int[a];
		int min=101;
		int max=0;
		int ans = 0;
		for(int i = 0; i<a; i++){
			int b = sc.nextInt();
			g[i]=b;
			if(b<min){
				min=b;
			}
			if(b>max){
				max=b;
			}
		}
		ans+=min;
		while(min<max){
		for(int i = 0; i <a; i++){
			if(g[i]>min){
				if(i==0){
					ans++;
				}else{
				if(g[i-1]>min){
					
				}else{
					ans++;
				}
				}
			}
		}
			min++;
		}
		System.out.println(ans);
	}
} public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[] g = new int[a];
		int min=101;
		int max=0;
		int ans = 0;
		for(int i = 0; i<a; i++){
			int b = sc.nextInt();
			g[i]=b;
			if(b<min){
				min=b;
			}
			if(b>max){
				max=b;
			}
		}
		ans+=min;
		while(min<max){
		for(int i = 0; i <a; i++){
			if(g[i]>min){
				if(i==0){
					ans++;
				}else{
				if(g[i-1]>min){
					
				}else{
					ans++;
				}
				}
			}
		}
			min++;
		}
		System.out.println(ans);
	}
} Main
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[] g = new int[a];
		int min=101;
		int max=0;
		int ans = 0;
		for(int i = 0; i<a; i++){
			int b = sc.nextInt();
			g[i]=b;
			if(b<min){
				min=b;
			}
			if(b>max){
				max=b;
			}
		}
		ans+=min;
		while(min<max){
		for(int i = 0; i <a; i++){
			if(g[i]>min){
				if(i==0){
					ans++;
				}else{
				if(g[i-1]>min){
					
				}else{
					ans++;
				}
				}
			}
		}
			min++;
		}
		System.out.println(ans);
	}
}