
import java.util.Arrays;
import java.util.Scanner;

/**
 * @author yoshizaki
 *
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        int flower = scanner.nextInt();
        int[] height = new int[flower];
        for(int i = 0; i < flower; i++) height[i] = scanner.nextInt();
        int count = 0;
        while(Arrays.stream(height).max().getAsInt() > 0) {
            boolean iscount = true;
            for(int i = 0; i < flower; i++) {
                if(iscount) {
                    if(height[i] == 0) continue;
                    count++;
                    height[i]--;
                    iscount = false;
                } else {
                    if(height[i] == 0) {
                        iscount = true;
                    } else {
                        height[i]--;
                    }
                }
            }
        }
        System.out.println(count);
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        int flower = scanner.nextInt();
        int[] height = new int[flower];
        for(int i = 0; i < flower; i++) height[i] = scanner.nextInt();
        int count = 0;
        while(Arrays.stream(height).max().getAsInt() > 0) {
            boolean iscount = true;
            for(int i = 0; i < flower; i++) {
                if(iscount) {
                    if(height[i] == 0) continue;
                    count++;
                    height[i]--;
                    iscount = false;
                } else {
                    if(height[i] == 0) {
                        iscount = true;
                    } else {
                        height[i]--;
                    }
                }
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        int flower = scanner.nextInt();
        int[] height = new int[flower];
        for(int i = 0; i < flower; i++) height[i] = scanner.nextInt();
        int count = 0;
        while(Arrays.stream(height).max().getAsInt() > 0) {
            boolean iscount = true;
            for(int i = 0; i < flower; i++) {
                if(iscount) {
                    if(height[i] == 0) continue;
                    count++;
                    height[i]--;
                    iscount = false;
                } else {
                    if(height[i] == 0) {
                        iscount = true;
                    } else {
                        height[i]--;
                    }
                }
            }
        }
        System.out.println(count);
    } main {
        Scanner scanner= new Scanner(System.in);
        int flower = scanner.nextInt();
        int[] height = new int[flower];
        for(int i = 0; i < flower; i++) height[i] = scanner.nextInt();
        int count = 0;
        while(Arrays.stream(height).max().getAsInt() > 0) {
            boolean iscount = true;
            for(int i = 0; i < flower; i++) {
                if(iscount) {
                    if(height[i] == 0) continue;
                    count++;
                    height[i]--;
                    iscount = false;
                } else {
                    if(height[i] == 0) {
                        iscount = true;
                    } else {
                        height[i]--;
                    }
                }
            }
        }
        System.out.println(count);
    } Scanner scanner= new Scanner(System.in); scanner new Scanner(System.in) int flower = scanner.nextInt(); flower scanner.nextInt() scanner.nextInt scanner int[] height = new int[flower]; height new int[flower] flower for(int i = 0; i < flower; i++) height[i] = scanner.nextInt(); int i = 0; int i = 0; i 0 i < flower i flower i++ i++ i height[i] = scanner.nextInt(); height[i] = scanner.nextInt() height[i] height i scanner.nextInt() scanner.nextInt scanner int count = 0; count 0 while(Arrays.stream(height).max().getAsInt() > 0) {
            boolean iscount = true;
            for(int i = 0; i < flower; i++) {
                if(iscount) {
                    if(height[i] == 0) continue;
                    count++;
                    height[i]--;
                    iscount = false;
                } else {
                    if(height[i] == 0) {
                        iscount = true;
                    } else {
                        height[i]--;
                    }
                }
            }
        } Arrays.stream(height).max().getAsInt() > 0 Arrays.stream(height).max().getAsInt() Arrays.stream(height).max().getAsInt Arrays.stream(height).max() Arrays.stream(height).max Arrays.stream(height) Arrays.stream Arrays height 0 {
            boolean iscount = true;
            for(int i = 0; i < flower; i++) {
                if(iscount) {
                    if(height[i] == 0) continue;
                    count++;
                    height[i]--;
                    iscount = false;
                } else {
                    if(height[i] == 0) {
                        iscount = true;
                    } else {
                        height[i]--;
                    }
                }
            }
        } boolean iscount = true; iscount true for(int i = 0; i < flower; i++) {
                if(iscount) {
                    if(height[i] == 0) continue;
                    count++;
                    height[i]--;
                    iscount = false;
                } else {
                    if(height[i] == 0) {
                        iscount = true;
                    } else {
                        height[i]--;
                    }
                }
            } int i = 0; int i = 0; i 0 i < flower i flower i++ i++ i {
                if(iscount) {
                    if(height[i] == 0) continue;
                    count++;
                    height[i]--;
                    iscount = false;
                } else {
                    if(height[i] == 0) {
                        iscount = true;
                    } else {
                        height[i]--;
                    }
                }
            } {
                if(iscount) {
                    if(height[i] == 0) continue;
                    count++;
                    height[i]--;
                    iscount = false;
                } else {
                    if(height[i] == 0) {
                        iscount = true;
                    } else {
                        height[i]--;
                    }
                }
            } if(iscount) {
                    if(height[i] == 0) continue;
                    count++;
                    height[i]--;
                    iscount = false;
                } else {
                    if(height[i] == 0) {
                        iscount = true;
                    } else {
                        height[i]--;
                    }
                } iscount {
                    if(height[i] == 0) continue;
                    count++;
                    height[i]--;
                    iscount = false;
                } if(height[i] == 0) continue; height[i] == 0 height[i] height i 0 continue; count++ count height[i]-- height[i] height i iscount = false iscount false {
                    if(height[i] == 0) {
                        iscount = true;
                    } else {
                        height[i]--;
                    }
                } if(height[i] == 0) {
                        iscount = true;
                    } else {
                        height[i]--;
                    } height[i] == 0 height[i] height i 0 {
                        iscount = true;
                    } iscount = true iscount true {
                        height[i]--;
                    } height[i]-- height[i] height i System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        int flower = scanner.nextInt();
        int[] height = new int[flower];
        for(int i = 0; i < flower; i++) height[i] = scanner.nextInt();
        int count = 0;
        while(Arrays.stream(height).max().getAsInt() > 0) {
            boolean iscount = true;
            for(int i = 0; i < flower; i++) {
                if(iscount) {
                    if(height[i] == 0) continue;
                    count++;
                    height[i]--;
                    iscount = false;
                } else {
                    if(height[i] == 0) {
                        iscount = true;
                    } else {
                        height[i]--;
                    }
                }
            }
        }
        System.out.println(count);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        int flower = scanner.nextInt();
        int[] height = new int[flower];
        for(int i = 0; i < flower; i++) height[i] = scanner.nextInt();
        int count = 0;
        while(Arrays.stream(height).max().getAsInt() > 0) {
            boolean iscount = true;
            for(int i = 0; i < flower; i++) {
                if(iscount) {
                    if(height[i] == 0) continue;
                    count++;
                    height[i]--;
                    iscount = false;
                } else {
                    if(height[i] == 0) {
                        iscount = true;
                    } else {
                        height[i]--;
                    }
                }
            }
        }
        System.out.println(count);
    }
} Main

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author yoshizaki
 *
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        int flower = scanner.nextInt();
        int[] height = new int[flower];
        for(int i = 0; i < flower; i++) height[i] = scanner.nextInt();
        int count = 0;
        while(Arrays.stream(height).max().getAsInt() > 0) {
            boolean iscount = true;
            for(int i = 0; i < flower; i++) {
                if(iscount) {
                    if(height[i] == 0) continue;
                    count++;
                    height[i]--;
                    iscount = false;
                } else {
                    if(height[i] == 0) {
                        iscount = true;
                    } else {
                        height[i]--;
                    }
                }
            }
        }
        System.out.println(count);
    }
}
