import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] a = new int[n];
    for (int i=0;i<n;i++){
      a[i] = scan.nextInt();
    }

    long sum = 0;
    while (true){
      boolean flag = true;
      for (int i=0;i<n;i++){
        if (a[i] == 0){
          if (flag == false){
            break;
          }
        }
        else{
          a[i] -= 1;
          flag = false;
        }
      }

      if (flag == true){
        System.out.println(sum);
        return;
      }

      sum += 1;


    }
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] a = new int[n];
    for (int i=0;i<n;i++){
      a[i] = scan.nextInt();
    }

    long sum = 0;
    while (true){
      boolean flag = true;
      for (int i=0;i<n;i++){
        if (a[i] == 0){
          if (flag == false){
            break;
          }
        }
        else{
          a[i] -= 1;
          flag = false;
        }
      }

      if (flag == true){
        System.out.println(sum);
        return;
      }

      sum += 1;


    }
  }
} Main public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] a = new int[n];
    for (int i=0;i<n;i++){
      a[i] = scan.nextInt();
    }

    long sum = 0;
    while (true){
      boolean flag = true;
      for (int i=0;i<n;i++){
        if (a[i] == 0){
          if (flag == false){
            break;
          }
        }
        else{
          a[i] -= 1;
          flag = false;
        }
      }

      if (flag == true){
        System.out.println(sum);
        return;
      }

      sum += 1;


    }
  } main {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] a = new int[n];
    for (int i=0;i<n;i++){
      a[i] = scan.nextInt();
    }

    long sum = 0;
    while (true){
      boolean flag = true;
      for (int i=0;i<n;i++){
        if (a[i] == 0){
          if (flag == false){
            break;
          }
        }
        else{
          a[i] -= 1;
          flag = false;
        }
      }

      if (flag == true){
        System.out.println(sum);
        return;
      }

      sum += 1;


    }
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int[] a = new int[n]; a new int[n] n for (int i=0;i<n;i++){
      a[i] = scan.nextInt();
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      a[i] = scan.nextInt();
    } {
      a[i] = scan.nextInt();
    } a[i] = scan.nextInt() a[i] a i scan.nextInt() scan.nextInt scan long sum = 0; sum 0 while (true){
      boolean flag = true;
      for (int i=0;i<n;i++){
        if (a[i] == 0){
          if (flag == false){
            break;
          }
        }
        else{
          a[i] -= 1;
          flag = false;
        }
      }

      if (flag == true){
        System.out.println(sum);
        return;
      }

      sum += 1;


    } true {
      boolean flag = true;
      for (int i=0;i<n;i++){
        if (a[i] == 0){
          if (flag == false){
            break;
          }
        }
        else{
          a[i] -= 1;
          flag = false;
        }
      }

      if (flag == true){
        System.out.println(sum);
        return;
      }

      sum += 1;


    } boolean flag = true; flag true for (int i=0;i<n;i++){
        if (a[i] == 0){
          if (flag == false){
            break;
          }
        }
        else{
          a[i] -= 1;
          flag = false;
        }
      } int i=0; int i=0; i 0 i<n i n i++ i++ i {
        if (a[i] == 0){
          if (flag == false){
            break;
          }
        }
        else{
          a[i] -= 1;
          flag = false;
        }
      } {
        if (a[i] == 0){
          if (flag == false){
            break;
          }
        }
        else{
          a[i] -= 1;
          flag = false;
        }
      } if (a[i] == 0){
          if (flag == false){
            break;
          }
        }
        else{
          a[i] -= 1;
          flag = false;
        } a[i] == 0 a[i] a i 0 {
          if (flag == false){
            break;
          }
        } if (flag == false){
            break;
          } flag == false flag false {
            break;
          } break; {
          a[i] -= 1;
          flag = false;
        } a[i] -= 1 a[i] a i 1 flag = false flag false if (flag == true){
        System.out.println(sum);
        return;
      } flag == true flag true {
        System.out.println(sum);
        return;
      } System.out.println(sum) System.out.println System.out System System.out sum return; sum += 1 sum 1 String[] args args public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] a = new int[n];
    for (int i=0;i<n;i++){
      a[i] = scan.nextInt();
    }

    long sum = 0;
    while (true){
      boolean flag = true;
      for (int i=0;i<n;i++){
        if (a[i] == 0){
          if (flag == false){
            break;
          }
        }
        else{
          a[i] -= 1;
          flag = false;
        }
      }

      if (flag == true){
        System.out.println(sum);
        return;
      }

      sum += 1;


    }
  }
} public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] a = new int[n];
    for (int i=0;i<n;i++){
      a[i] = scan.nextInt();
    }

    long sum = 0;
    while (true){
      boolean flag = true;
      for (int i=0;i<n;i++){
        if (a[i] == 0){
          if (flag == false){
            break;
          }
        }
        else{
          a[i] -= 1;
          flag = false;
        }
      }

      if (flag == true){
        System.out.println(sum);
        return;
      }

      sum += 1;


    }
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] a = new int[n];
    for (int i=0;i<n;i++){
      a[i] = scan.nextInt();
    }

    long sum = 0;
    while (true){
      boolean flag = true;
      for (int i=0;i<n;i++){
        if (a[i] == 0){
          if (flag == false){
            break;
          }
        }
        else{
          a[i] -= 1;
          flag = false;
        }
      }

      if (flag == true){
        System.out.println(sum);
        return;
      }

      sum += 1;


    }
  }
}
