import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int ans = 0;
		int[] h = new int[N];
		int max = 0;
		int height = 0;
		for (int i = 0; i < N; i++) {
			h[i] = reader.nextInt();
			if (h[i] > max) {
				max = h[i];
			}
		}
		while (height < max) {
			for (int i = 0; i < N; i++) {
				if (h[i] > height) {
					ans++;
					if (i < N-1 && h[i+1] > height) {
						ans--;
					}
				}
			}
			height++;
		}
		System.out.print(ans);
		reader.close();

	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int ans = 0;
		int[] h = new int[N];
		int max = 0;
		int height = 0;
		for (int i = 0; i < N; i++) {
			h[i] = reader.nextInt();
			if (h[i] > max) {
				max = h[i];
			}
		}
		while (height < max) {
			for (int i = 0; i < N; i++) {
				if (h[i] > height) {
					ans++;
					if (i < N-1 && h[i+1] > height) {
						ans--;
					}
				}
			}
			height++;
		}
		System.out.print(ans);
		reader.close();

	}

} Main public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int ans = 0;
		int[] h = new int[N];
		int max = 0;
		int height = 0;
		for (int i = 0; i < N; i++) {
			h[i] = reader.nextInt();
			if (h[i] > max) {
				max = h[i];
			}
		}
		while (height < max) {
			for (int i = 0; i < N; i++) {
				if (h[i] > height) {
					ans++;
					if (i < N-1 && h[i+1] > height) {
						ans--;
					}
				}
			}
			height++;
		}
		System.out.print(ans);
		reader.close();

	} main {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int ans = 0;
		int[] h = new int[N];
		int max = 0;
		int height = 0;
		for (int i = 0; i < N; i++) {
			h[i] = reader.nextInt();
			if (h[i] > max) {
				max = h[i];
			}
		}
		while (height < max) {
			for (int i = 0; i < N; i++) {
				if (h[i] > height) {
					ans++;
					if (i < N-1 && h[i+1] > height) {
						ans--;
					}
				}
			}
			height++;
		}
		System.out.print(ans);
		reader.close();

	} Scanner reader = new Scanner(System.in); reader new Scanner(System.in) int N = reader.nextInt(); N reader.nextInt() reader.nextInt reader int ans = 0; ans 0 int[] h = new int[N]; h new int[N] N int max = 0; max 0 int height = 0; height 0 for (int i = 0; i < N; i++) {
			h[i] = reader.nextInt();
			if (h[i] > max) {
				max = h[i];
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			h[i] = reader.nextInt();
			if (h[i] > max) {
				max = h[i];
			}
		} {
			h[i] = reader.nextInt();
			if (h[i] > max) {
				max = h[i];
			}
		} h[i] = reader.nextInt() h[i] h i reader.nextInt() reader.nextInt reader if (h[i] > max) {
				max = h[i];
			} h[i] > max h[i] h i max {
				max = h[i];
			} max = h[i] max h[i] h i while (height < max) {
			for (int i = 0; i < N; i++) {
				if (h[i] > height) {
					ans++;
					if (i < N-1 && h[i+1] > height) {
						ans--;
					}
				}
			}
			height++;
		} height < max height max {
			for (int i = 0; i < N; i++) {
				if (h[i] > height) {
					ans++;
					if (i < N-1 && h[i+1] > height) {
						ans--;
					}
				}
			}
			height++;
		} for (int i = 0; i < N; i++) {
				if (h[i] > height) {
					ans++;
					if (i < N-1 && h[i+1] > height) {
						ans--;
					}
				}
			} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
				if (h[i] > height) {
					ans++;
					if (i < N-1 && h[i+1] > height) {
						ans--;
					}
				}
			} {
				if (h[i] > height) {
					ans++;
					if (i < N-1 && h[i+1] > height) {
						ans--;
					}
				}
			} if (h[i] > height) {
					ans++;
					if (i < N-1 && h[i+1] > height) {
						ans--;
					}
				} h[i] > height h[i] h i height {
					ans++;
					if (i < N-1 && h[i+1] > height) {
						ans--;
					}
				} ans++ ans if (i < N-1 && h[i+1] > height) {
						ans--;
					} i < N-1 && h[i+1] > height i < N-1 i N-1 N 1 h[i+1] > height h[i+1] h i+1 i 1 height {
						ans--;
					} ans-- ans height++ height System.out.print(ans) System.out.print System.out System System.out ans reader.close() reader.close reader String[] args args public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int ans = 0;
		int[] h = new int[N];
		int max = 0;
		int height = 0;
		for (int i = 0; i < N; i++) {
			h[i] = reader.nextInt();
			if (h[i] > max) {
				max = h[i];
			}
		}
		while (height < max) {
			for (int i = 0; i < N; i++) {
				if (h[i] > height) {
					ans++;
					if (i < N-1 && h[i+1] > height) {
						ans--;
					}
				}
			}
			height++;
		}
		System.out.print(ans);
		reader.close();

	}

} public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int ans = 0;
		int[] h = new int[N];
		int max = 0;
		int height = 0;
		for (int i = 0; i < N; i++) {
			h[i] = reader.nextInt();
			if (h[i] > max) {
				max = h[i];
			}
		}
		while (height < max) {
			for (int i = 0; i < N; i++) {
				if (h[i] > height) {
					ans++;
					if (i < N-1 && h[i+1] > height) {
						ans--;
					}
				}
			}
			height++;
		}
		System.out.print(ans);
		reader.close();

	}

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int ans = 0;
		int[] h = new int[N];
		int max = 0;
		int height = 0;
		for (int i = 0; i < N; i++) {
			h[i] = reader.nextInt();
			if (h[i] > max) {
				max = h[i];
			}
		}
		while (height < max) {
			for (int i = 0; i < N; i++) {
				if (h[i] > height) {
					ans++;
					if (i < N-1 && h[i+1] > height) {
						ans--;
					}
				}
			}
			height++;
		}
		System.out.print(ans);
		reader.close();

	}

}