import java.util.*;
import java.lang.*;
import java.io.*;

class Main{
    static FastScanner sc = new FastScanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    public static void Solve(int arr[]){
        int n=arr.length;
        long dp[]=new long[n];
        dp[0]=0;
        dp[1]=Math.abs(arr[0]-arr[1]);
        for(int i=2;i<n;i++){
            dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
        }

        out.println(dp[n-1]);
    }
    public static void main (String[] args) throws Exception {
        int n=sc.nextInt();
        int arr[]=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }
        Solve(arr);
        out.close();

    }    
    
}
class FastScanner
{

    final private int BUFFER_SIZE = 1 << 17;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public FastScanner(InputStream in)
    {
        din = new DataInputStream(in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }
    public String nextLine() throws Exception
    {
        StringBuffer sb = new StringBuffer("");
        byte c = read();
        while (c <= ' ') c = read();
        do
        {
            sb.append((char)c);
            c = read();
        }
        while(c > ' ');
        return sb.toString();
    }

    public char nextChar() throws Exception
    {
        byte c = read();
        while(c <= ' ') c = read();
        return (char)c;
    }

    public int nextInt() throws Exception
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = c == '-';
        if (neg) c = read();
        do
        {
            ret = ret * 10 + c - '0';
            c = read();
        }
        while (c > ' ');
        if (neg) return -ret;
        return ret;
    }

    public long nextLong() throws Exception
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = c == '-';
        if (neg) c = read();
        do
        {
            ret = ret * 10 + c - '0';
            c = read();
        }
        while (c > ' ');
        if (neg) return -ret;
        return ret;
    } 

    private void fillBuffer() throws Exception
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1) buffer[0] = -1;
    }

    private byte read() throws Exception
    {
        if (bufferPointer == bytesRead) fillBuffer();
        return buffer[bufferPointer++];
    }
    public double nextDouble() throws Exception
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do
        {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    
}

 import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java class Main{
    static FastScanner sc = new FastScanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    public static void Solve(int arr[]){
        int n=arr.length;
        long dp[]=new long[n];
        dp[0]=0;
        dp[1]=Math.abs(arr[0]-arr[1]);
        for(int i=2;i<n;i++){
            dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
        }

        out.println(dp[n-1]);
    }
    public static void main (String[] args) throws Exception {
        int n=sc.nextInt();
        int arr[]=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }
        Solve(arr);
        out.close();

    }    
    
} Main static FastScanner sc = new FastScanner(System.in); sc new FastScanner(System.in) static PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) public static void Solve(int arr[]){
        int n=arr.length;
        long dp[]=new long[n];
        dp[0]=0;
        dp[1]=Math.abs(arr[0]-arr[1]);
        for(int i=2;i<n;i++){
            dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
        }

        out.println(dp[n-1]);
    } Solve {
        int n=arr.length;
        long dp[]=new long[n];
        dp[0]=0;
        dp[1]=Math.abs(arr[0]-arr[1]);
        for(int i=2;i<n;i++){
            dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
        }

        out.println(dp[n-1]);
    } int n=arr.length; n arr.length arr arr.length long dp[]=new long[n]; dp new long[n] n dp[0]=0 dp[0] dp 0 0 dp[1]=Math.abs(arr[0]-arr[1]) dp[1] dp 1 Math.abs(arr[0]-arr[1]) Math.abs Math arr[0]-arr[1] arr[0] arr 0 arr[1] arr 1 for(int i=2;i<n;i++){
            dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
        } int i=2; int i=2; i 2 i<n i n i++ i++ i {
            dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
        } {
            dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
        } dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i-2]-arr[i])) dp[i] dp i Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i-2]-arr[i])) Math.min Math dp[i-1]+Math.abs(arr[i]-arr[i-1]) dp[i-1] dp i-1 i 1 Math.abs(arr[i]-arr[i-1]) Math.abs Math arr[i]-arr[i-1] arr[i] arr i arr[i-1] arr i-1 i 1 dp[i-2]+Math.abs(arr[i-2]-arr[i]) dp[i-2] dp i-2 i 2 Math.abs(arr[i-2]-arr[i]) Math.abs Math arr[i-2]-arr[i] arr[i-2] arr i-2 i 2 arr[i] arr i out.println(dp[n-1]) out.println out dp[n-1] dp n-1 n 1 int arr[] arr public static void main (String[] args) throws Exception {
        int n=sc.nextInt();
        int arr[]=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }
        Solve(arr);
        out.close();

    } main {
        int n=sc.nextInt();
        int arr[]=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }
        Solve(arr);
        out.close();

    } int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int arr[]=new int[n]; arr new int[n] n for(int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            arr[i]=sc.nextInt();
        } {
            arr[i]=sc.nextInt();
        } arr[i]=sc.nextInt() arr[i] arr i sc.nextInt() sc.nextInt sc Solve(arr) Solve arr out.close() out.close out String[] args args class FastScanner
{

    final private int BUFFER_SIZE = 1 << 17;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public FastScanner(InputStream in)
    {
        din = new DataInputStream(in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }
    public String nextLine() throws Exception
    {
        StringBuffer sb = new StringBuffer("");
        byte c = read();
        while (c <= ' ') c = read();
        do
        {
            sb.append((char)c);
            c = read();
        }
        while(c > ' ');
        return sb.toString();
    }

    public char nextChar() throws Exception
    {
        byte c = read();
        while(c <= ' ') c = read();
        return (char)c;
    }

    public int nextInt() throws Exception
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = c == '-';
        if (neg) c = read();
        do
        {
            ret = ret * 10 + c - '0';
            c = read();
        }
        while (c > ' ');
        if (neg) return -ret;
        return ret;
    }

    public long nextLong() throws Exception
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = c == '-';
        if (neg) c = read();
        do
        {
            ret = ret * 10 + c - '0';
            c = read();
        }
        while (c > ' ');
        if (neg) return -ret;
        return ret;
    } 

    private void fillBuffer() throws Exception
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1) buffer[0] = -1;
    }

    private byte read() throws Exception
    {
        if (bufferPointer == bytesRead) fillBuffer();
        return buffer[bufferPointer++];
    }
    public double nextDouble() throws Exception
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do
        {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    
} FastScanner final private int BUFFER_SIZE = 1 << 17; BUFFER_SIZE 1 << 17 1 17 private DataInputStream din; din private byte[] buffer; buffer private int bufferPointer bufferPointer bytesRead; bytesRead public FastScanner(InputStream in)
    {
        din = new DataInputStream(in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    } FastScanner {
        din = new DataInputStream(in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    } din = new DataInputStream(in) din new DataInputStream(in) buffer = new byte[BUFFER_SIZE] buffer new byte[BUFFER_SIZE] BUFFER_SIZE bufferPointer = bytesRead = 0 bufferPointer bytesRead = 0 bytesRead 0 InputStream in in public String nextLine() throws Exception
    {
        StringBuffer sb = new StringBuffer("");
        byte c = read();
        while (c <= ' ') c = read();
        do
        {
            sb.append((char)c);
            c = read();
        }
        while(c > ' ');
        return sb.toString();
    } nextLine {
        StringBuffer sb = new StringBuffer("");
        byte c = read();
        while (c <= ' ') c = read();
        do
        {
            sb.append((char)c);
            c = read();
        }
        while(c > ' ');
        return sb.toString();
    } StringBuffer sb = new StringBuffer(""); sb new StringBuffer("") byte c = read(); c read() read while (c <= ' ') c = read(); c <= ' ' c ' ' c = read() c read() read do
        {
            sb.append((char)c);
            c = read();
        }
        while(c > ' '); c > ' ' c ' ' {
            sb.append((char)c);
            c = read();
        } sb.append((char)c) sb.append sb (char)c c = read() c read() read return sb.toString(); sb.toString() sb.toString sb public char nextChar() throws Exception
    {
        byte c = read();
        while(c <= ' ') c = read();
        return (char)c;
    } nextChar {
        byte c = read();
        while(c <= ' ') c = read();
        return (char)c;
    } byte c = read(); c read() read while(c <= ' ') c = read(); c <= ' ' c ' ' c = read() c read() read return (char)c; (char)c public int nextInt() throws Exception
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = c == '-';
        if (neg) c = read();
        do
        {
            ret = ret * 10 + c - '0';
            c = read();
        }
        while (c > ' ');
        if (neg) return -ret;
        return ret;
    } nextInt {
        int ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = c == '-';
        if (neg) c = read();
        do
        {
            ret = ret * 10 + c - '0';
            c = read();
        }
        while (c > ' ');
        if (neg) return -ret;
        return ret;
    } int ret = 0; ret 0 byte c = read(); c read() read while (c <= ' ') c = read(); c <= ' ' c ' ' c = read() c read() read boolean neg = c == '-'; neg c == '-' c '-' if (neg) c = read(); neg c = read() c read() read do
        {
            ret = ret * 10 + c - '0';
            c = read();
        }
        while (c > ' '); c > ' ' c ' ' {
            ret = ret * 10 + c - '0';
            c = read();
        } ret = ret * 10 + c - '0' ret ret * 10 + c - '0' ret * 10 + c ret * 10 ret 10 c '0' c = read() c read() read if (neg) return -ret; neg return -ret; -ret ret return ret; ret public long nextLong() throws Exception
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = c == '-';
        if (neg) c = read();
        do
        {
            ret = ret * 10 + c - '0';
            c = read();
        }
        while (c > ' ');
        if (neg) return -ret;
        return ret;
    } nextLong {
        long ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = c == '-';
        if (neg) c = read();
        do
        {
            ret = ret * 10 + c - '0';
            c = read();
        }
        while (c > ' ');
        if (neg) return -ret;
        return ret;
    } long ret = 0; ret 0 byte c = read(); c read() read while (c <= ' ') c = read(); c <= ' ' c ' ' c = read() c read() read boolean neg = c == '-'; neg c == '-' c '-' if (neg) c = read(); neg c = read() c read() read do
        {
            ret = ret * 10 + c - '0';
            c = read();
        }
        while (c > ' '); c > ' ' c ' ' {
            ret = ret * 10 + c - '0';
            c = read();
        } ret = ret * 10 + c - '0' ret ret * 10 + c - '0' ret * 10 + c ret * 10 ret 10 c '0' c = read() c read() read if (neg) return -ret; neg return -ret; -ret ret return ret; ret private void fillBuffer() throws Exception
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1) buffer[0] = -1;
    } fillBuffer {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1) buffer[0] = -1;
    } bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE) bytesRead din.read(buffer, bufferPointer = 0, BUFFER_SIZE) din.read din buffer bufferPointer = 0 bufferPointer 0 BUFFER_SIZE if (bytesRead == -1) buffer[0] = -1; bytesRead == -1 bytesRead -1 1 buffer[0] = -1 buffer[0] buffer 0 -1 1 private byte read() throws Exception
    {
        if (bufferPointer == bytesRead) fillBuffer();
        return buffer[bufferPointer++];
    } read {
        if (bufferPointer == bytesRead) fillBuffer();
        return buffer[bufferPointer++];
    } if (bufferPointer == bytesRead) fillBuffer(); bufferPointer == bytesRead bufferPointer bytesRead fillBuffer() fillBuffer return buffer[bufferPointer++]; buffer[bufferPointer++] buffer bufferPointer++ bufferPointer public double nextDouble() throws Exception
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do
        {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    } nextDouble {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do
        {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    } double ret = 0 ret 0 div = 1; div 1 byte c = read(); c read() read while (c <= ' ')
            c = read(); c <= ' ' c ' ' c = read() c read() read boolean neg = (c == '-'); neg (c == '-') c '-' if (neg)
            c = read(); neg c = read() c read() read do
        {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9'); (c = read()) >= '0' && c <= '9' (c = read()) >= '0' (c = read()) c read() read '0' c <= '9' c '9' {
            ret = ret * 10 + c - '0';
        } ret = ret * 10 + c - '0' ret ret * 10 + c - '0' ret * 10 + c ret * 10 ret 10 c '0' if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        } c == '.' c '.' {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        } while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            } (c = read()) >= '0' && c <= '9' (c = read()) >= '0' (c = read()) c read() read '0' c <= '9' c '9' {
                ret += (c - '0') / (div *= 10);
            } ret += (c - '0') / (div *= 10) ret (c - '0') / (div *= 10) (c - '0') c '0' (div *= 10) div 10 if (neg)
            return -ret; neg return -ret; -ret ret return ret; ret
import java.util.*;
import java.lang.*;
import java.io.*;

class Main{
    static FastScanner sc = new FastScanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    public static void Solve(int arr[]){
        int n=arr.length;
        long dp[]=new long[n];
        dp[0]=0;
        dp[1]=Math.abs(arr[0]-arr[1]);
        for(int i=2;i<n;i++){
            dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
        }

        out.println(dp[n-1]);
    }
    public static void main (String[] args) throws Exception {
        int n=sc.nextInt();
        int arr[]=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }
        Solve(arr);
        out.close();

    }    
    
}
class FastScanner
{

    final private int BUFFER_SIZE = 1 << 17;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public FastScanner(InputStream in)
    {
        din = new DataInputStream(in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }
    public String nextLine() throws Exception
    {
        StringBuffer sb = new StringBuffer("");
        byte c = read();
        while (c <= ' ') c = read();
        do
        {
            sb.append((char)c);
            c = read();
        }
        while(c > ' ');
        return sb.toString();
    }

    public char nextChar() throws Exception
    {
        byte c = read();
        while(c <= ' ') c = read();
        return (char)c;
    }

    public int nextInt() throws Exception
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = c == '-';
        if (neg) c = read();
        do
        {
            ret = ret * 10 + c - '0';
            c = read();
        }
        while (c > ' ');
        if (neg) return -ret;
        return ret;
    }

    public long nextLong() throws Exception
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = c == '-';
        if (neg) c = read();
        do
        {
            ret = ret * 10 + c - '0';
            c = read();
        }
        while (c > ' ');
        if (neg) return -ret;
        return ret;
    } 

    private void fillBuffer() throws Exception
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1) buffer[0] = -1;
    }

    private byte read() throws Exception
    {
        if (bufferPointer == bytesRead) fillBuffer();
        return buffer[bufferPointer++];
    }
    public double nextDouble() throws Exception
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do
        {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    
}


