import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Random;
import java.util.Scanner;
public class Main {
	static Scanner sc = new Scanner(System.in);static void p(int i) {System.out.println(i);}static void p(long i) {System.out.println(i);}static void p(String i) {System.out.println(i);}static void p(double i) {System.out.println(i);}
	
	
	public static void main(String[] args) {
		int N=sc.nextInt();
		
		int h[]=new int[N];
		
		for(int i=0;i<N;i++) {
			h[i]=sc.nextInt();
		}
		
		int ans=0;
		
		for(int i=1;i<=100;i++) {
			
			for(int a=0;a<N;a++) {
				
				if(h[a]>=i) {
					while(h[a]>=i) {
						a++;
						if(a==N) {
							break;
						}
					}
					ans++;
					
				}
				
				
				
				
			}
			
			
		}
		p(ans);
	}
	
}
	 import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.Collections; Collections java.util import java.util.Random; Random java.util import java.util.Scanner; Scanner java.util public class Main {
	static Scanner sc = new Scanner(System.in);static void p(int i) {System.out.println(i);}static void p(long i) {System.out.println(i);}static void p(String i) {System.out.println(i);}static void p(double i) {System.out.println(i);}
	
	
	public static void main(String[] args) {
		int N=sc.nextInt();
		
		int h[]=new int[N];
		
		for(int i=0;i<N;i++) {
			h[i]=sc.nextInt();
		}
		
		int ans=0;
		
		for(int i=1;i<=100;i++) {
			
			for(int a=0;a<N;a++) {
				
				if(h[a]>=i) {
					while(h[a]>=i) {
						a++;
						if(a==N) {
							break;
						}
					}
					ans++;
					
				}
				
				
				
				
			}
			
			
		}
		p(ans);
	}
	
} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) static void p(int i) {System.out.println(i);} p {System.out.println(i);} System.out.println(i) System.out.println System.out System System.out i int i i static void p(long i) {System.out.println(i);} p {System.out.println(i);} System.out.println(i) System.out.println System.out System System.out i long i i static void p(String i) {System.out.println(i);} p {System.out.println(i);} System.out.println(i) System.out.println System.out System System.out i String i i static void p(double i) {System.out.println(i);} p {System.out.println(i);} System.out.println(i) System.out.println System.out System System.out i double i i public static void main(String[] args) {
		int N=sc.nextInt();
		
		int h[]=new int[N];
		
		for(int i=0;i<N;i++) {
			h[i]=sc.nextInt();
		}
		
		int ans=0;
		
		for(int i=1;i<=100;i++) {
			
			for(int a=0;a<N;a++) {
				
				if(h[a]>=i) {
					while(h[a]>=i) {
						a++;
						if(a==N) {
							break;
						}
					}
					ans++;
					
				}
				
				
				
				
			}
			
			
		}
		p(ans);
	} main {
		int N=sc.nextInt();
		
		int h[]=new int[N];
		
		for(int i=0;i<N;i++) {
			h[i]=sc.nextInt();
		}
		
		int ans=0;
		
		for(int i=1;i<=100;i++) {
			
			for(int a=0;a<N;a++) {
				
				if(h[a]>=i) {
					while(h[a]>=i) {
						a++;
						if(a==N) {
							break;
						}
					}
					ans++;
					
				}
				
				
				
				
			}
			
			
		}
		p(ans);
	} 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]=sc.nextInt() h[i] h i sc.nextInt() sc.nextInt sc int ans=0; ans 0 for(int i=1;i<=100;i++) {
			
			for(int a=0;a<N;a++) {
				
				if(h[a]>=i) {
					while(h[a]>=i) {
						a++;
						if(a==N) {
							break;
						}
					}
					ans++;
					
				}
				
				
				
				
			}
			
			
		} int i=1; int i=1; i 1 i<=100 i 100 i++ i++ i {
			
			for(int a=0;a<N;a++) {
				
				if(h[a]>=i) {
					while(h[a]>=i) {
						a++;
						if(a==N) {
							break;
						}
					}
					ans++;
					
				}
				
				
				
				
			}
			
			
		} {
			
			for(int a=0;a<N;a++) {
				
				if(h[a]>=i) {
					while(h[a]>=i) {
						a++;
						if(a==N) {
							break;
						}
					}
					ans++;
					
				}
				
				
				
				
			}
			
			
		} for(int a=0;a<N;a++) {
				
				if(h[a]>=i) {
					while(h[a]>=i) {
						a++;
						if(a==N) {
							break;
						}
					}
					ans++;
					
				}
				
				
				
				
			} int a=0; int a=0; a 0 a<N a N a++ a++ a {
				
				if(h[a]>=i) {
					while(h[a]>=i) {
						a++;
						if(a==N) {
							break;
						}
					}
					ans++;
					
				}
				
				
				
				
			} {
				
				if(h[a]>=i) {
					while(h[a]>=i) {
						a++;
						if(a==N) {
							break;
						}
					}
					ans++;
					
				}
				
				
				
				
			} if(h[a]>=i) {
					while(h[a]>=i) {
						a++;
						if(a==N) {
							break;
						}
					}
					ans++;
					
				} h[a]>=i h[a] h a i {
					while(h[a]>=i) {
						a++;
						if(a==N) {
							break;
						}
					}
					ans++;
					
				} while(h[a]>=i) {
						a++;
						if(a==N) {
							break;
						}
					} h[a]>=i h[a] h a i {
						a++;
						if(a==N) {
							break;
						}
					} a++ a if(a==N) {
							break;
						} a==N a N {
							break;
						} break; ans++ ans p(ans) p ans String[] args args public class Main {
	static Scanner sc = new Scanner(System.in);static void p(int i) {System.out.println(i);}static void p(long i) {System.out.println(i);}static void p(String i) {System.out.println(i);}static void p(double i) {System.out.println(i);}
	
	
	public static void main(String[] args) {
		int N=sc.nextInt();
		
		int h[]=new int[N];
		
		for(int i=0;i<N;i++) {
			h[i]=sc.nextInt();
		}
		
		int ans=0;
		
		for(int i=1;i<=100;i++) {
			
			for(int a=0;a<N;a++) {
				
				if(h[a]>=i) {
					while(h[a]>=i) {
						a++;
						if(a==N) {
							break;
						}
					}
					ans++;
					
				}
				
				
				
				
			}
			
			
		}
		p(ans);
	}
	
} public class Main {
	static Scanner sc = new Scanner(System.in);static void p(int i) {System.out.println(i);}static void p(long i) {System.out.println(i);}static void p(String i) {System.out.println(i);}static void p(double i) {System.out.println(i);}
	
	
	public static void main(String[] args) {
		int N=sc.nextInt();
		
		int h[]=new int[N];
		
		for(int i=0;i<N;i++) {
			h[i]=sc.nextInt();
		}
		
		int ans=0;
		
		for(int i=1;i<=100;i++) {
			
			for(int a=0;a<N;a++) {
				
				if(h[a]>=i) {
					while(h[a]>=i) {
						a++;
						if(a==N) {
							break;
						}
					}
					ans++;
					
				}
				
				
				
				
			}
			
			
		}
		p(ans);
	}
	
} Main
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Random;
import java.util.Scanner;
public class Main {
	static Scanner sc = new Scanner(System.in);static void p(int i) {System.out.println(i);}static void p(long i) {System.out.println(i);}static void p(String i) {System.out.println(i);}static void p(double i) {System.out.println(i);}
	
	
	public static void main(String[] args) {
		int N=sc.nextInt();
		
		int h[]=new int[N];
		
		for(int i=0;i<N;i++) {
			h[i]=sc.nextInt();
		}
		
		int ans=0;
		
		for(int i=1;i<=100;i++) {
			
			for(int a=0;a<N;a++) {
				
				if(h[a]>=i) {
					while(h[a]>=i) {
						a++;
						if(a==N) {
							break;
						}
					}
					ans++;
					
				}
				
				
				
				
			}
			
			
		}
		p(ans);
	}
	
}
	
