import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    int n = Integer.parseInt(sl[0]);

    int a[] = new int[101];

    s = r.readLine();
    sl = s.split(" ");
    for(int i = 0; i < n; i++)
    {
    	a[i + 1] = Integer.parseInt(sl[i]);
    }

    int v = 0;
    int c = 0;
    for(int i = 0; i <= n; i++)
    {
        if(c < a[i])
        {
        	v += a[i] - c;
        }
        c = a[i];
    }

    System.out.println(v);
  }

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    int n = Integer.parseInt(sl[0]);

    int a[] = new int[101];

    s = r.readLine();
    sl = s.split(" ");
    for(int i = 0; i < n; i++)
    {
    	a[i + 1] = Integer.parseInt(sl[i]);
    }

    int v = 0;
    int c = 0;
    for(int i = 0; i <= n; i++)
    {
        if(c < a[i])
        {
        	v += a[i] - c;
        }
        c = a[i];
    }

    System.out.println(v);
  }

} Main public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    int n = Integer.parseInt(sl[0]);

    int a[] = new int[101];

    s = r.readLine();
    sl = s.split(" ");
    for(int i = 0; i < n; i++)
    {
    	a[i + 1] = Integer.parseInt(sl[i]);
    }

    int v = 0;
    int c = 0;
    for(int i = 0; i <= n; i++)
    {
        if(c < a[i])
        {
        	v += a[i] - c;
        }
        c = a[i];
    }

    System.out.println(v);
  } main {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    int n = Integer.parseInt(sl[0]);

    int a[] = new int[101];

    s = r.readLine();
    sl = s.split(" ");
    for(int i = 0; i < n; i++)
    {
    	a[i + 1] = Integer.parseInt(sl[i]);
    }

    int v = 0;
    int c = 0;
    for(int i = 0; i <= n; i++)
    {
        if(c < a[i])
        {
        	v += a[i] - c;
        }
        c = a[i];
    }

    System.out.println(v);
  } BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1); r new BufferedReader(new InputStreamReader(System.in), 1) String s; s String sl[]; sl s = r.readLine() s r.readLine() r.readLine r sl = s.split(" ") sl s.split(" ") s.split s " " int n = Integer.parseInt(sl[0]); n Integer.parseInt(sl[0]) Integer.parseInt Integer sl[0] sl 0 int a[] = new int[101]; a new int[101] 101 s = r.readLine() s r.readLine() r.readLine r sl = s.split(" ") sl s.split(" ") s.split s " " for(int i = 0; i < n; i++)
    {
    	a[i + 1] = Integer.parseInt(sl[i]);
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
    	a[i + 1] = Integer.parseInt(sl[i]);
    } {
    	a[i + 1] = Integer.parseInt(sl[i]);
    } a[i + 1] = Integer.parseInt(sl[i]) a[i + 1] a i + 1 i 1 Integer.parseInt(sl[i]) Integer.parseInt Integer sl[i] sl i int v = 0; v 0 int c = 0; c 0 for(int i = 0; i <= n; i++)
    {
        if(c < a[i])
        {
        	v += a[i] - c;
        }
        c = a[i];
    } int i = 0; int i = 0; i 0 i <= n i n i++ i++ i {
        if(c < a[i])
        {
        	v += a[i] - c;
        }
        c = a[i];
    } {
        if(c < a[i])
        {
        	v += a[i] - c;
        }
        c = a[i];
    } if(c < a[i])
        {
        	v += a[i] - c;
        } c < a[i] c a[i] a i {
        	v += a[i] - c;
        } v += a[i] - c v a[i] - c a[i] a i c c = a[i] c a[i] a i System.out.println(v) System.out.println System.out System System.out v String[] args args public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    int n = Integer.parseInt(sl[0]);

    int a[] = new int[101];

    s = r.readLine();
    sl = s.split(" ");
    for(int i = 0; i < n; i++)
    {
    	a[i + 1] = Integer.parseInt(sl[i]);
    }

    int v = 0;
    int c = 0;
    for(int i = 0; i <= n; i++)
    {
        if(c < a[i])
        {
        	v += a[i] - c;
        }
        c = a[i];
    }

    System.out.println(v);
  }

} public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    int n = Integer.parseInt(sl[0]);

    int a[] = new int[101];

    s = r.readLine();
    sl = s.split(" ");
    for(int i = 0; i < n; i++)
    {
    	a[i + 1] = Integer.parseInt(sl[i]);
    }

    int v = 0;
    int c = 0;
    for(int i = 0; i <= n; i++)
    {
        if(c < a[i])
        {
        	v += a[i] - c;
        }
        c = a[i];
    }

    System.out.println(v);
  }

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    int n = Integer.parseInt(sl[0]);

    int a[] = new int[101];

    s = r.readLine();
    sl = s.split(" ");
    for(int i = 0; i < n; i++)
    {
    	a[i + 1] = Integer.parseInt(sl[i]);
    }

    int v = 0;
    int c = 0;
    for(int i = 0; i <= n; i++)
    {
        if(c < a[i])
        {
        	v += a[i] - c;
        }
        c = a[i];
    }

    System.out.println(v);
  }

}