import java.util.Scanner;
public class Main {

	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int h[]=new int[N];
		int z=0,y=0,x=1,max=0,n=1,s=0;
		while(z<N){
			h[z]=stdIn.nextInt();
			if(h[z]>max)
				max=h[z];
			z++;
		}z=0;
		while(x<=max){
			while(y<N){
				if(h[y]<x){
					if(n==0)
						n=1;
				}
				else{
					if(n==1)
						s++;
					n=0;
				}
				y++;
			}
			x++;
			n=1;
			y=0;
			z+=s;
			s=0;
		}
		System.out.println(z);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int h[]=new int[N];
		int z=0,y=0,x=1,max=0,n=1,s=0;
		while(z<N){
			h[z]=stdIn.nextInt();
			if(h[z]>max)
				max=h[z];
			z++;
		}z=0;
		while(x<=max){
			while(y<N){
				if(h[y]<x){
					if(n==0)
						n=1;
				}
				else{
					if(n==1)
						s++;
					n=0;
				}
				y++;
			}
			x++;
			n=1;
			y=0;
			z+=s;
			s=0;
		}
		System.out.println(z);
	}
} Main public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int h[]=new int[N];
		int z=0,y=0,x=1,max=0,n=1,s=0;
		while(z<N){
			h[z]=stdIn.nextInt();
			if(h[z]>max)
				max=h[z];
			z++;
		}z=0;
		while(x<=max){
			while(y<N){
				if(h[y]<x){
					if(n==0)
						n=1;
				}
				else{
					if(n==1)
						s++;
					n=0;
				}
				y++;
			}
			x++;
			n=1;
			y=0;
			z+=s;
			s=0;
		}
		System.out.println(z);
	} main {
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int h[]=new int[N];
		int z=0,y=0,x=1,max=0,n=1,s=0;
		while(z<N){
			h[z]=stdIn.nextInt();
			if(h[z]>max)
				max=h[z];
			z++;
		}z=0;
		while(x<=max){
			while(y<N){
				if(h[y]<x){
					if(n==0)
						n=1;
				}
				else{
					if(n==1)
						s++;
					n=0;
				}
				y++;
			}
			x++;
			n=1;
			y=0;
			z+=s;
			s=0;
		}
		System.out.println(z);
	} Scanner stdIn=new Scanner(System.in); stdIn new Scanner(System.in) int N=stdIn.nextInt(); N stdIn.nextInt() stdIn.nextInt stdIn int h[]=new int[N]; h new int[N] N int z=0 z 0 y=0 y 0 x=1 x 1 max=0 max 0 n=1 n 1 s=0; s 0 while(z<N){
			h[z]=stdIn.nextInt();
			if(h[z]>max)
				max=h[z];
			z++;
		} z<N z N {
			h[z]=stdIn.nextInt();
			if(h[z]>max)
				max=h[z];
			z++;
		} h[z]=stdIn.nextInt() h[z] h z stdIn.nextInt() stdIn.nextInt stdIn if(h[z]>max)
				max=h[z]; h[z]>max h[z] h z max max=h[z] max h[z] h z z++ z z=0 z 0 while(x<=max){
			while(y<N){
				if(h[y]<x){
					if(n==0)
						n=1;
				}
				else{
					if(n==1)
						s++;
					n=0;
				}
				y++;
			}
			x++;
			n=1;
			y=0;
			z+=s;
			s=0;
		} x<=max x max {
			while(y<N){
				if(h[y]<x){
					if(n==0)
						n=1;
				}
				else{
					if(n==1)
						s++;
					n=0;
				}
				y++;
			}
			x++;
			n=1;
			y=0;
			z+=s;
			s=0;
		} while(y<N){
				if(h[y]<x){
					if(n==0)
						n=1;
				}
				else{
					if(n==1)
						s++;
					n=0;
				}
				y++;
			} y<N y N {
				if(h[y]<x){
					if(n==0)
						n=1;
				}
				else{
					if(n==1)
						s++;
					n=0;
				}
				y++;
			} if(h[y]<x){
					if(n==0)
						n=1;
				}
				else{
					if(n==1)
						s++;
					n=0;
				} h[y]<x h[y] h y x {
					if(n==0)
						n=1;
				} if(n==0)
						n=1; n==0 n 0 n=1 n 1 {
					if(n==1)
						s++;
					n=0;
				} if(n==1)
						s++; n==1 n 1 s++ s n=0 n 0 y++ y x++ x n=1 n 1 y=0 y 0 z+=s z s s=0 s 0 System.out.println(z) System.out.println System.out System System.out z String[] args args public class Main {

	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int h[]=new int[N];
		int z=0,y=0,x=1,max=0,n=1,s=0;
		while(z<N){
			h[z]=stdIn.nextInt();
			if(h[z]>max)
				max=h[z];
			z++;
		}z=0;
		while(x<=max){
			while(y<N){
				if(h[y]<x){
					if(n==0)
						n=1;
				}
				else{
					if(n==1)
						s++;
					n=0;
				}
				y++;
			}
			x++;
			n=1;
			y=0;
			z+=s;
			s=0;
		}
		System.out.println(z);
	}
} public class Main {

	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int h[]=new int[N];
		int z=0,y=0,x=1,max=0,n=1,s=0;
		while(z<N){
			h[z]=stdIn.nextInt();
			if(h[z]>max)
				max=h[z];
			z++;
		}z=0;
		while(x<=max){
			while(y<N){
				if(h[y]<x){
					if(n==0)
						n=1;
				}
				else{
					if(n==1)
						s++;
					n=0;
				}
				y++;
			}
			x++;
			n=1;
			y=0;
			z+=s;
			s=0;
		}
		System.out.println(z);
	}
} Main
import java.util.Scanner;
public class Main {

	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int h[]=new int[N];
		int z=0,y=0,x=1,max=0,n=1,s=0;
		while(z<N){
			h[z]=stdIn.nextInt();
			if(h[z]>max)
				max=h[z];
			z++;
		}z=0;
		while(x<=max){
			while(y<N){
				if(h[y]<x){
					if(n==0)
						n=1;
				}
				else{
					if(n==1)
						s++;
					n=0;
				}
				y++;
			}
			x++;
			n=1;
			y=0;
			z+=s;
			s=0;
		}
		System.out.println(z);
	}
}
