In a kindergarten, the children are being divided into groups. The teacher put the children in a line and associated each child with his or her integer charisma value. Each child should go to exactly one group. Each group should be a nonempty segment of consecutive children of a line. A group's sociability is the maximum difference of charisma of two children in the group (in particular, if the group consists of one child, its sociability equals a zero). 

The teacher wants to divide the children into some number of groups in such way that the total sociability of the groups is maximum. Help him find this value.

Input

The first line contains integer n — the number of children in the line (1 ≤ n ≤ 106).

The second line contains n integers ai — the charisma of the i-th child ( - 109 ≤ ai ≤ 109).

Output

Print the maximum possible total sociability of all groups.

Examples

Input

5
1 2 3 1 2


Output

3


Input

3
3 3 3


Output

0

Note

In the first test sample one of the possible variants of an division is following: the first three children form a group with sociability 2, and the two remaining children form a group with sociability 1.

In the second test sample any division leads to the same result, the sociability will be equal to 0 in each group.
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.List;
 import java.util.*;
 public class realfast implements Runnable 
  {
    private static final int INF = (int) 1e9;
    long in= 998244353;
    long fac[]= new long[3000];
    public  void solve() throws IOException 
    {
      

      int n = readInt();

      int arr[]= new int[n+1];

      long seg1[]= new long[4*n+4];
      long seg2[]= new long[4*n+4];

      long dp[]= new long[n+1];


      for(int i =1;i<=n;i++)
        arr[i]= readInt();

      build(seg1,1,n,0,arr,true);
      build(seg2,1,n,0,arr,false);
      for(int i =n-1;i>=1;i--)
      {
          dp[i]=dp[i+1];
        long val1 = max(seg1,1,n,0,i+1);

        long val2 = max(seg2,1,n,0,i+1);

        val1= val1-arr[i];
        val2= val2 +arr[i];

        dp[i]=Math.max(dp[i],Math.max(val1,val2));

        if(i==1)
            break;

        add(seg1,1,n,0,i-1,dp[i]);
        add(seg2,1,n,0,i-1,dp[i]);


      }

      out.println(dp[1]);


    }
    public long max(long seg[] , int l , int r , int index , int i)
    {

        if(l==r)
        {
            
            return seg[index];
        }

        int mid = l+(r-l)/2;
        if(l>=i)
           return seg[index];
        if(i<=mid)
            return Math.max(max(seg,l,mid,2*index+1,i),seg[2*index+2]);
        else
            return max(seg,mid+1,r,2*index+2,i);

    }
    public  void add(long seg[] , int l , int r , int index , int i,long val)
    {
        

        if(l==r)
        {
            seg[index]= seg[index]+val;
            return ;
        }
        int mid = l+(r-l)/2;

        if(i<=mid)
            add(seg,l,mid,2*index+1,i,val);
        else
            add(seg,mid+1,r,2*index+2,i,val);

        seg[index]=Math.max(seg[2*index+1],seg[2*index+2]);
         return ;
                 
    }
    public void build (long seg[] , int l , int r , int index , int arr[], boolean check)
    {
        if(l==r)
        {
            if(check)
                seg[index]=arr[l];
            else
                seg[index]=-arr[l];
            return ;
        }

        int mid = l+(r-l)/2;

        build(seg,l,mid,2*index+1,arr,check);
        build(seg,mid+1,r,2*index+2,arr,check);

        seg[index]=Math.max(seg[2*index+1],seg[2*index+2]);
        

    }


   
   
    public int value (int seg[], int left , int right ,int index, int l, int r)
    {
            
            if(left>right)
            {
              return -100000000;
            }
            if(right<l||left>r)
                return -100000000;
            if(left>=l&&right<=r)
                return seg[index];
            int mid = left+(right-left)/2;
            int val = value(seg,left,mid,2*index+1,l,r);
            int val2 = value(seg,mid+1,right,2*index+2,l,r);
            return Math.max(val,val2);

    }
   
    public int gcd(int a , int b )
    {
      if(a<b)
      {
        int t =a;
        a=b;
        b=t;
      }
      if(a%b==0)
        return b ;
      return gcd(b,a%b);
    }
    public long pow(long n , long p,long m)
    {
         if(p==0)
            return 1;
        long val = pow(n,p/2,m);;
        val= (val*val)%m;
        if(p%2==0)
            return val;
        else
            return (val*n)%m;
    }
    
    
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public static void main(String[] args) {
        new Thread(null, new realfast(), "", 128 * (1L << 20)).start();
    }
 
    private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    private BufferedReader reader;
    private StringTokenizer tokenizer;
    private PrintWriter out;
 
    @Override
    public void run() {
        try {
            if (ONLINE_JUDGE || !new File("input.txt").exists()) {
                reader = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                reader = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            }
            solve();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                // nothing
            }
            out.close();
        }
    }
 
    private String readString() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
 
    @SuppressWarnings("unused")
    private int readInt() throws IOException {
        return Integer.parseInt(readString());
    }
 
    @SuppressWarnings("unused")
    private long readLong() throws IOException {
        return Long.parseLong(readString());
    }
 
    @SuppressWarnings("unused")
    private double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }
}
class edge implements Comparable<edge>{
    int val ;
    int color;
    
    edge(int u, int v)
    {
       this.val=u;
       this.color=v;
    }
    public int compareTo(edge e)
    {
        return this.val-e.val;
    }
}