import java.util.*;

public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int N = sc.nextInt();
    int[] h = new int[N];

    int max = 0;
    for (int i=0; i<N; i++) {
      h[i] = sc.nextInt();
      if (h[i] > max) max = h[i];
    }

    int count = 0;
    for (int t=0; t<max; t++) {
      if (h[0] > 0) count++;
      for (int i = 1; i < N; i++) {
        if (h[i-1] <= 0 && h[i] > 0) {
          count++;
        }
      }
      for (int i=0; i<N; i++) {
        h[i]--;
      }
    }

    System.out.println(count);

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

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int N = sc.nextInt();
    int[] h = new int[N];

    int max = 0;
    for (int i=0; i<N; i++) {
      h[i] = sc.nextInt();
      if (h[i] > max) max = h[i];
    }

    int count = 0;
    for (int t=0; t<max; t++) {
      if (h[0] > 0) count++;
      for (int i = 1; i < N; i++) {
        if (h[i-1] <= 0 && h[i] > 0) {
          count++;
        }
      }
      for (int i=0; i<N; i++) {
        h[i]--;
      }
    }

    System.out.println(count);

  }
} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {

    int N = sc.nextInt();
    int[] h = new int[N];

    int max = 0;
    for (int i=0; i<N; i++) {
      h[i] = sc.nextInt();
      if (h[i] > max) max = h[i];
    }

    int count = 0;
    for (int t=0; t<max; t++) {
      if (h[0] > 0) count++;
      for (int i = 1; i < N; i++) {
        if (h[i-1] <= 0 && h[i] > 0) {
          count++;
        }
      }
      for (int i=0; i<N; i++) {
        h[i]--;
      }
    }

    System.out.println(count);

  } main {

    int N = sc.nextInt();
    int[] h = new int[N];

    int max = 0;
    for (int i=0; i<N; i++) {
      h[i] = sc.nextInt();
      if (h[i] > max) max = h[i];
    }

    int count = 0;
    for (int t=0; t<max; t++) {
      if (h[0] > 0) count++;
      for (int i = 1; i < N; i++) {
        if (h[i-1] <= 0 && h[i] > 0) {
          count++;
        }
      }
      for (int i=0; i<N; i++) {
        h[i]--;
      }
    }

    System.out.println(count);

  } int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] h = new int[N]; h new int[N] N int max = 0; max 0 for (int i=0; i<N; i++) {
      h[i] = sc.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] = sc.nextInt();
      if (h[i] > max) max = h[i];
    } {
      h[i] = sc.nextInt();
      if (h[i] > max) max = h[i];
    } h[i] = sc.nextInt() h[i] h i sc.nextInt() sc.nextInt sc if (h[i] > max) max = h[i]; h[i] > max h[i] h i max max = h[i] max h[i] h i int count = 0; count 0 for (int t=0; t<max; t++) {
      if (h[0] > 0) count++;
      for (int i = 1; i < N; i++) {
        if (h[i-1] <= 0 && h[i] > 0) {
          count++;
        }
      }
      for (int i=0; i<N; i++) {
        h[i]--;
      }
    } int t=0; int t=0; t 0 t<max t max t++ t++ t {
      if (h[0] > 0) count++;
      for (int i = 1; i < N; i++) {
        if (h[i-1] <= 0 && h[i] > 0) {
          count++;
        }
      }
      for (int i=0; i<N; i++) {
        h[i]--;
      }
    } {
      if (h[0] > 0) count++;
      for (int i = 1; i < N; i++) {
        if (h[i-1] <= 0 && h[i] > 0) {
          count++;
        }
      }
      for (int i=0; i<N; i++) {
        h[i]--;
      }
    } if (h[0] > 0) count++; h[0] > 0 h[0] h 0 0 count++ count for (int i = 1; i < N; i++) {
        if (h[i-1] <= 0 && h[i] > 0) {
          count++;
        }
      } int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
        if (h[i-1] <= 0 && h[i] > 0) {
          count++;
        }
      } {
        if (h[i-1] <= 0 && h[i] > 0) {
          count++;
        }
      } if (h[i-1] <= 0 && h[i] > 0) {
          count++;
        } h[i-1] <= 0 && h[i] > 0 h[i-1] <= 0 h[i-1] h i-1 i 1 0 h[i] > 0 h[i] h i 0 {
          count++;
        } count++ count for (int i=0; i<N; i++) {
        h[i]--;
      } int i=0; int i=0; i 0 i<N i N i++ i++ i {
        h[i]--;
      } {
        h[i]--;
      } h[i]-- h[i] h i System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int N = sc.nextInt();
    int[] h = new int[N];

    int max = 0;
    for (int i=0; i<N; i++) {
      h[i] = sc.nextInt();
      if (h[i] > max) max = h[i];
    }

    int count = 0;
    for (int t=0; t<max; t++) {
      if (h[0] > 0) count++;
      for (int i = 1; i < N; i++) {
        if (h[i-1] <= 0 && h[i] > 0) {
          count++;
        }
      }
      for (int i=0; i<N; i++) {
        h[i]--;
      }
    }

    System.out.println(count);

  }
} public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int N = sc.nextInt();
    int[] h = new int[N];

    int max = 0;
    for (int i=0; i<N; i++) {
      h[i] = sc.nextInt();
      if (h[i] > max) max = h[i];
    }

    int count = 0;
    for (int t=0; t<max; t++) {
      if (h[0] > 0) count++;
      for (int i = 1; i < N; i++) {
        if (h[i-1] <= 0 && h[i] > 0) {
          count++;
        }
      }
      for (int i=0; i<N; i++) {
        h[i]--;
      }
    }

    System.out.println(count);

  }
} Main
import java.util.*;

public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int N = sc.nextInt();
    int[] h = new int[N];

    int max = 0;
    for (int i=0; i<N; i++) {
      h[i] = sc.nextInt();
      if (h[i] > max) max = h[i];
    }

    int count = 0;
    for (int t=0; t<max; t++) {
      if (h[0] > 0) count++;
      for (int i = 1; i < N; i++) {
        if (h[i-1] <= 0 && h[i] > 0) {
          count++;
        }
      }
      for (int i=0; i<N; i++) {
        h[i]--;
      }
    }

    System.out.println(count);

  }
}