
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 1; i <= 100; i++) {
            int r = 0;
            int a = h[0];
            if (a - i >= 0) {
                r = 1;
            } else {
                r = -1;
            }
            int cc = 0;
            for (int j = 0; j < n; j++) {
                if (a - i >= 0) {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                } else {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                }

            }
            if (a - i >= 0) {
                count += cc  / 2  + 1;
            } else {
                count += (cc + 1)  / 2 ;
            }
        }
        System.out.println(count);

    }

} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 1; i <= 100; i++) {
            int r = 0;
            int a = h[0];
            if (a - i >= 0) {
                r = 1;
            } else {
                r = -1;
            }
            int cc = 0;
            for (int j = 0; j < n; j++) {
                if (a - i >= 0) {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                } else {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                }

            }
            if (a - i >= 0) {
                count += cc  / 2  + 1;
            } else {
                count += (cc + 1)  / 2 ;
            }
        }
        System.out.println(count);

    }

} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 1; i <= 100; i++) {
            int r = 0;
            int a = h[0];
            if (a - i >= 0) {
                r = 1;
            } else {
                r = -1;
            }
            int cc = 0;
            for (int j = 0; j < n; j++) {
                if (a - i >= 0) {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                } else {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                }

            }
            if (a - i >= 0) {
                count += cc  / 2  + 1;
            } else {
                count += (cc + 1)  / 2 ;
            }
        }
        System.out.println(count);

    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 1; i <= 100; i++) {
            int r = 0;
            int a = h[0];
            if (a - i >= 0) {
                r = 1;
            } else {
                r = -1;
            }
            int cc = 0;
            for (int j = 0; j < n; j++) {
                if (a - i >= 0) {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                } else {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                }

            }
            if (a - i >= 0) {
                count += cc  / 2  + 1;
            } else {
                count += (cc + 1)  / 2 ;
            }
        }
        System.out.println(count);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) 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 count = 0; count 0 for (int i = 1; i <= 100; i++) {
            int r = 0;
            int a = h[0];
            if (a - i >= 0) {
                r = 1;
            } else {
                r = -1;
            }
            int cc = 0;
            for (int j = 0; j < n; j++) {
                if (a - i >= 0) {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                } else {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                }

            }
            if (a - i >= 0) {
                count += cc  / 2  + 1;
            } else {
                count += (cc + 1)  / 2 ;
            }
        } int i = 1; int i = 1; i 1 i <= 100 i 100 i++ i++ i {
            int r = 0;
            int a = h[0];
            if (a - i >= 0) {
                r = 1;
            } else {
                r = -1;
            }
            int cc = 0;
            for (int j = 0; j < n; j++) {
                if (a - i >= 0) {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                } else {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                }

            }
            if (a - i >= 0) {
                count += cc  / 2  + 1;
            } else {
                count += (cc + 1)  / 2 ;
            }
        } {
            int r = 0;
            int a = h[0];
            if (a - i >= 0) {
                r = 1;
            } else {
                r = -1;
            }
            int cc = 0;
            for (int j = 0; j < n; j++) {
                if (a - i >= 0) {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                } else {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                }

            }
            if (a - i >= 0) {
                count += cc  / 2  + 1;
            } else {
                count += (cc + 1)  / 2 ;
            }
        } int r = 0; r 0 int a = h[0]; a h[0] h 0 if (a - i >= 0) {
                r = 1;
            } else {
                r = -1;
            } a - i >= 0 a - i a i 0 {
                r = 1;
            } r = 1 r 1 {
                r = -1;
            } r = -1 r -1 1 int cc = 0; cc 0 for (int j = 0; j < n; j++) {
                if (a - i >= 0) {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                } else {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                }

            } int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
                if (a - i >= 0) {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                } else {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                }

            } {
                if (a - i >= 0) {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                } else {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                }

            } if (a - i >= 0) {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                } else {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                } a - i >= 0 a - i a i 0 {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                } if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    } r == 1 && h[j] - i < 0 r == 1 r 1 h[j] - i < 0 h[j] - i h[j] h j i 0 {
                        r = -1;
                        cc++;
                    } r = -1 r -1 1 cc++ cc if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    } r == -1 && h[j] - i >= 0 r == -1 r -1 1 h[j] - i >= 0 h[j] - i h[j] h j i 0 {
                        r = 1;
                        cc++;
                    } r = 1 r 1 cc++ cc {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                } if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    } r == 1 && h[j] - i < 0 r == 1 r 1 h[j] - i < 0 h[j] - i h[j] h j i 0 {
                        r = -1;
                        cc++;
                    } r = -1 r -1 1 cc++ cc if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    } r == -1 && h[j] - i >= 0 r == -1 r -1 1 h[j] - i >= 0 h[j] - i h[j] h j i 0 {
                        r = 1;
                        cc++;
                    } r = 1 r 1 cc++ cc if (a - i >= 0) {
                count += cc  / 2  + 1;
            } else {
                count += (cc + 1)  / 2 ;
            } a - i >= 0 a - i a i 0 {
                count += cc  / 2  + 1;
            } count += cc  / 2  + 1 count cc  / 2  + 1 cc  / 2 cc 2 1 {
                count += (cc + 1)  / 2 ;
            } count += (cc + 1)  / 2 count (cc + 1)  / 2 (cc + 1) cc 1 2 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 sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 1; i <= 100; i++) {
            int r = 0;
            int a = h[0];
            if (a - i >= 0) {
                r = 1;
            } else {
                r = -1;
            }
            int cc = 0;
            for (int j = 0; j < n; j++) {
                if (a - i >= 0) {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                } else {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                }

            }
            if (a - i >= 0) {
                count += cc  / 2  + 1;
            } else {
                count += (cc + 1)  / 2 ;
            }
        }
        System.out.println(count);

    }

} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 1; i <= 100; i++) {
            int r = 0;
            int a = h[0];
            if (a - i >= 0) {
                r = 1;
            } else {
                r = -1;
            }
            int cc = 0;
            for (int j = 0; j < n; j++) {
                if (a - i >= 0) {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                } else {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                }

            }
            if (a - i >= 0) {
                count += cc  / 2  + 1;
            } else {
                count += (cc + 1)  / 2 ;
            }
        }
        System.out.println(count);

    }

} Main

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 1; i <= 100; i++) {
            int r = 0;
            int a = h[0];
            if (a - i >= 0) {
                r = 1;
            } else {
                r = -1;
            }
            int cc = 0;
            for (int j = 0; j < n; j++) {
                if (a - i >= 0) {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                } else {
                    if (r == 1 && h[j] - i < 0) {
                        r = -1;
                        cc++;
                    }
                    if (r == -1 && h[j] - i >= 0) {
                        r = 1;
                        cc++;
                    }
                }

            }
            if (a - i >= 0) {
                count += cc  / 2  + 1;
            } else {
                count += (cc + 1)  / 2 ;
            }
        }
        System.out.println(count);

    }

}