import java.util.*;

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

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

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

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

    static void solve(int n, int[] h, int[] dp) {
        for(int i=2;i<n;i++)    {
            int s1 = Math.abs(h[i]-h[i-1]) + dp[i-1];
            int s2 = Math.abs(h[i]-h[i-2]) + dp[i-2];
            dp[i] = Math.min(s1, s2);
        }
    }
} Main
import java.util.*;

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

    static void solve(int n, int[] h, int[] dp) {
        for(int i=2;i<n;i++)    {
            int s1 = Math.abs(h[i]-h[i-1]) + dp[i-1];
            int s2 = Math.abs(h[i]-h[i-2]) + dp[i-2];
            dp[i] = Math.min(s1, s2);
        }
    }
}