import java.util.*;

public class Main{
    static int[]dp = new int[100000];
    static int[]stones = new int[100000];
    static int N;
    public static void main(String[]args){
        Scanner in = new Scanner(System.in);
        N = in.nextInt();
        for(int i = 0 ; i < N ; ++i)
            stones[i] = in.nextInt();
        solve();
        System.out.println(dp[N-1]);
    }
    public static void solve(){
        dp[0] = 0;
        dp[1] = Math.abs(stones[1]-stones[0]);
        for(int i = 2 ; i < N ; ++i){
            dp[i] = Math.min(dp[i-1] + Math.abs(stones[i]-stones[i-1]),
            dp[i-2]+Math.abs(stones[i]-stones[i-2]));
        }
    }
} import java.util.*; util.* java public class Main{
    static int[]dp = new int[100000];
    static int[]stones = new int[100000];
    static int N;
    public static void main(String[]args){
        Scanner in = new Scanner(System.in);
        N = in.nextInt();
        for(int i = 0 ; i < N ; ++i)
            stones[i] = in.nextInt();
        solve();
        System.out.println(dp[N-1]);
    }
    public static void solve(){
        dp[0] = 0;
        dp[1] = Math.abs(stones[1]-stones[0]);
        for(int i = 2 ; i < N ; ++i){
            dp[i] = Math.min(dp[i-1] + Math.abs(stones[i]-stones[i-1]),
            dp[i-2]+Math.abs(stones[i]-stones[i-2]));
        }
    }
} Main static int[]dp = new int[100000]; dp new int[100000] 100000 static int[]stones = new int[100000]; stones new int[100000] 100000 static int N; N public static void main(String[]args){
        Scanner in = new Scanner(System.in);
        N = in.nextInt();
        for(int i = 0 ; i < N ; ++i)
            stones[i] = in.nextInt();
        solve();
        System.out.println(dp[N-1]);
    } main {
        Scanner in = new Scanner(System.in);
        N = in.nextInt();
        for(int i = 0 ; i < N ; ++i)
            stones[i] = in.nextInt();
        solve();
        System.out.println(dp[N-1]);
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) N = in.nextInt() N in.nextInt() in.nextInt in for(int i = 0 ; i < N ; ++i)
            stones[i] = in.nextInt(); int i = 0 ; int i = 0 ; i 0 i < N i N ++i ++i i stones[i] = in.nextInt(); stones[i] = in.nextInt() stones[i] stones i in.nextInt() in.nextInt in solve() solve System.out.println(dp[N-1]) System.out.println System.out System System.out dp[N-1] dp N-1 N 1 String[]args args public static void solve(){
        dp[0] = 0;
        dp[1] = Math.abs(stones[1]-stones[0]);
        for(int i = 2 ; i < N ; ++i){
            dp[i] = Math.min(dp[i-1] + Math.abs(stones[i]-stones[i-1]),
            dp[i-2]+Math.abs(stones[i]-stones[i-2]));
        }
    } solve {
        dp[0] = 0;
        dp[1] = Math.abs(stones[1]-stones[0]);
        for(int i = 2 ; i < N ; ++i){
            dp[i] = Math.min(dp[i-1] + Math.abs(stones[i]-stones[i-1]),
            dp[i-2]+Math.abs(stones[i]-stones[i-2]));
        }
    } dp[0] = 0 dp[0] dp 0 0 dp[1] = Math.abs(stones[1]-stones[0]) dp[1] dp 1 Math.abs(stones[1]-stones[0]) Math.abs Math stones[1]-stones[0] stones[1] stones 1 stones[0] stones 0 for(int i = 2 ; i < N ; ++i){
            dp[i] = Math.min(dp[i-1] + Math.abs(stones[i]-stones[i-1]),
            dp[i-2]+Math.abs(stones[i]-stones[i-2]));
        } int i = 2 ; int i = 2 ; i 2 i < N i N ++i ++i i {
            dp[i] = Math.min(dp[i-1] + Math.abs(stones[i]-stones[i-1]),
            dp[i-2]+Math.abs(stones[i]-stones[i-2]));
        } {
            dp[i] = Math.min(dp[i-1] + Math.abs(stones[i]-stones[i-1]),
            dp[i-2]+Math.abs(stones[i]-stones[i-2]));
        } dp[i] = Math.min(dp[i-1] + Math.abs(stones[i]-stones[i-1]),
            dp[i-2]+Math.abs(stones[i]-stones[i-2])) dp[i] dp i Math.min(dp[i-1] + Math.abs(stones[i]-stones[i-1]),
            dp[i-2]+Math.abs(stones[i]-stones[i-2])) Math.min Math dp[i-1] + Math.abs(stones[i]-stones[i-1]) dp[i-1] dp i-1 i 1 Math.abs(stones[i]-stones[i-1]) Math.abs Math stones[i]-stones[i-1] stones[i] stones i stones[i-1] stones i-1 i 1 dp[i-2]+Math.abs(stones[i]-stones[i-2]) dp[i-2] dp i-2 i 2 Math.abs(stones[i]-stones[i-2]) Math.abs Math stones[i]-stones[i-2] stones[i] stones i stones[i-2] stones i-2 i 2 public class Main{
    static int[]dp = new int[100000];
    static int[]stones = new int[100000];
    static int N;
    public static void main(String[]args){
        Scanner in = new Scanner(System.in);
        N = in.nextInt();
        for(int i = 0 ; i < N ; ++i)
            stones[i] = in.nextInt();
        solve();
        System.out.println(dp[N-1]);
    }
    public static void solve(){
        dp[0] = 0;
        dp[1] = Math.abs(stones[1]-stones[0]);
        for(int i = 2 ; i < N ; ++i){
            dp[i] = Math.min(dp[i-1] + Math.abs(stones[i]-stones[i-1]),
            dp[i-2]+Math.abs(stones[i]-stones[i-2]));
        }
    }
} public class Main{
    static int[]dp = new int[100000];
    static int[]stones = new int[100000];
    static int N;
    public static void main(String[]args){
        Scanner in = new Scanner(System.in);
        N = in.nextInt();
        for(int i = 0 ; i < N ; ++i)
            stones[i] = in.nextInt();
        solve();
        System.out.println(dp[N-1]);
    }
    public static void solve(){
        dp[0] = 0;
        dp[1] = Math.abs(stones[1]-stones[0]);
        for(int i = 2 ; i < N ; ++i){
            dp[i] = Math.min(dp[i-1] + Math.abs(stones[i]-stones[i-1]),
            dp[i-2]+Math.abs(stones[i]-stones[i-2]));
        }
    }
} Main
import java.util.*;

public class Main{
    static int[]dp = new int[100000];
    static int[]stones = new int[100000];
    static int N;
    public static void main(String[]args){
        Scanner in = new Scanner(System.in);
        N = in.nextInt();
        for(int i = 0 ; i < N ; ++i)
            stones[i] = in.nextInt();
        solve();
        System.out.println(dp[N-1]);
    }
    public static void solve(){
        dp[0] = 0;
        dp[1] = Math.abs(stones[1]-stones[0]);
        for(int i = 2 ; i < N ; ++i){
            dp[i] = Math.min(dp[i-1] + Math.abs(stones[i]-stones[i-1]),
            dp[i-2]+Math.abs(stones[i]-stones[i-2]));
        }
    }
}