import java.util.Arrays;
import java.util.Scanner;

public class Main {



    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        int heights[] = new int[i];
        for (int j = 0; j < heights.length; j++) {
            heights[j] = scanner.nextInt();
        }
        long numOfWays = getNumOfWays(heights);
        System.out.println(numOfWays);
    }

    private static long getNumOfWays(int hei[]) {
        int dp[] = new int[hei.length];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[dp.length - 1] = 0;
        for (int i = dp.length - 2; i >= 0; i--) {
            if (i + 1 < dp.length)
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 1]) + dp[i + 1]);
            if (i + 2 < dp.length) {
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 2]) + dp[i + 2]);
            }
        }
        return dp[0];
    }
    

} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {



    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        int heights[] = new int[i];
        for (int j = 0; j < heights.length; j++) {
            heights[j] = scanner.nextInt();
        }
        long numOfWays = getNumOfWays(heights);
        System.out.println(numOfWays);
    }

    private static long getNumOfWays(int hei[]) {
        int dp[] = new int[hei.length];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[dp.length - 1] = 0;
        for (int i = dp.length - 2; i >= 0; i--) {
            if (i + 1 < dp.length)
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 1]) + dp[i + 1]);
            if (i + 2 < dp.length) {
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 2]) + dp[i + 2]);
            }
        }
        return dp[0];
    }
    

} Main public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        int heights[] = new int[i];
        for (int j = 0; j < heights.length; j++) {
            heights[j] = scanner.nextInt();
        }
        long numOfWays = getNumOfWays(heights);
        System.out.println(numOfWays);
    } main {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        int heights[] = new int[i];
        for (int j = 0; j < heights.length; j++) {
            heights[j] = scanner.nextInt();
        }
        long numOfWays = getNumOfWays(heights);
        System.out.println(numOfWays);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int i = scanner.nextInt(); i scanner.nextInt() scanner.nextInt scanner int heights[] = new int[i]; heights new int[i] i for (int j = 0; j < heights.length; j++) {
            heights[j] = scanner.nextInt();
        } int j = 0; int j = 0; j 0 j < heights.length j heights.length heights heights.length j++ j++ j {
            heights[j] = scanner.nextInt();
        } {
            heights[j] = scanner.nextInt();
        } heights[j] = scanner.nextInt() heights[j] heights j scanner.nextInt() scanner.nextInt scanner long numOfWays = getNumOfWays(heights); numOfWays getNumOfWays(heights) getNumOfWays heights System.out.println(numOfWays) System.out.println System.out System System.out numOfWays String[] args args private static long getNumOfWays(int hei[]) {
        int dp[] = new int[hei.length];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[dp.length - 1] = 0;
        for (int i = dp.length - 2; i >= 0; i--) {
            if (i + 1 < dp.length)
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 1]) + dp[i + 1]);
            if (i + 2 < dp.length) {
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 2]) + dp[i + 2]);
            }
        }
        return dp[0];
    } getNumOfWays {
        int dp[] = new int[hei.length];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[dp.length - 1] = 0;
        for (int i = dp.length - 2; i >= 0; i--) {
            if (i + 1 < dp.length)
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 1]) + dp[i + 1]);
            if (i + 2 < dp.length) {
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 2]) + dp[i + 2]);
            }
        }
        return dp[0];
    } int dp[] = new int[hei.length]; dp new int[hei.length] hei.length hei hei.length Arrays.fill(dp, Integer.MAX_VALUE) Arrays.fill Arrays dp Integer.MAX_VALUE Integer Integer.MAX_VALUE dp[dp.length - 1] = 0 dp[dp.length - 1] dp dp.length - 1 dp.length dp dp.length 1 0 for (int i = dp.length - 2; i >= 0; i--) {
            if (i + 1 < dp.length)
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 1]) + dp[i + 1]);
            if (i + 2 < dp.length) {
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 2]) + dp[i + 2]);
            }
        } int i = dp.length - 2; int i = dp.length - 2; i dp.length - 2 dp.length dp dp.length 2 i >= 0 i 0 i-- i-- i {
            if (i + 1 < dp.length)
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 1]) + dp[i + 1]);
            if (i + 2 < dp.length) {
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 2]) + dp[i + 2]);
            }
        } {
            if (i + 1 < dp.length)
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 1]) + dp[i + 1]);
            if (i + 2 < dp.length) {
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 2]) + dp[i + 2]);
            }
        } if (i + 1 < dp.length)
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 1]) + dp[i + 1]); i + 1 < dp.length i + 1 i 1 dp.length dp dp.length dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 1]) + dp[i + 1]) dp[i] dp i Math.min(dp[i], Math.abs(hei[i] - hei[i + 1]) + dp[i + 1]) Math.min Math dp[i] dp i Math.abs(hei[i] - hei[i + 1]) + dp[i + 1] Math.abs(hei[i] - hei[i + 1]) Math.abs Math hei[i] - hei[i + 1] hei[i] hei i hei[i + 1] hei i + 1 i 1 dp[i + 1] dp i + 1 i 1 if (i + 2 < dp.length) {
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 2]) + dp[i + 2]);
            } i + 2 < dp.length i + 2 i 2 dp.length dp dp.length {
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 2]) + dp[i + 2]);
            } dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 2]) + dp[i + 2]) dp[i] dp i Math.min(dp[i], Math.abs(hei[i] - hei[i + 2]) + dp[i + 2]) Math.min Math dp[i] dp i Math.abs(hei[i] - hei[i + 2]) + dp[i + 2] Math.abs(hei[i] - hei[i + 2]) Math.abs Math hei[i] - hei[i + 2] hei[i] hei i hei[i + 2] hei i + 2 i 2 dp[i + 2] dp i + 2 i 2 return dp[0]; dp[0] dp 0 int hei[] hei public class Main {



    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        int heights[] = new int[i];
        for (int j = 0; j < heights.length; j++) {
            heights[j] = scanner.nextInt();
        }
        long numOfWays = getNumOfWays(heights);
        System.out.println(numOfWays);
    }

    private static long getNumOfWays(int hei[]) {
        int dp[] = new int[hei.length];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[dp.length - 1] = 0;
        for (int i = dp.length - 2; i >= 0; i--) {
            if (i + 1 < dp.length)
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 1]) + dp[i + 1]);
            if (i + 2 < dp.length) {
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 2]) + dp[i + 2]);
            }
        }
        return dp[0];
    }
    

} public class Main {



    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        int heights[] = new int[i];
        for (int j = 0; j < heights.length; j++) {
            heights[j] = scanner.nextInt();
        }
        long numOfWays = getNumOfWays(heights);
        System.out.println(numOfWays);
    }

    private static long getNumOfWays(int hei[]) {
        int dp[] = new int[hei.length];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[dp.length - 1] = 0;
        for (int i = dp.length - 2; i >= 0; i--) {
            if (i + 1 < dp.length)
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 1]) + dp[i + 1]);
            if (i + 2 < dp.length) {
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 2]) + dp[i + 2]);
            }
        }
        return dp[0];
    }
    

} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {



    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        int heights[] = new int[i];
        for (int j = 0; j < heights.length; j++) {
            heights[j] = scanner.nextInt();
        }
        long numOfWays = getNumOfWays(heights);
        System.out.println(numOfWays);
    }

    private static long getNumOfWays(int hei[]) {
        int dp[] = new int[hei.length];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[dp.length - 1] = 0;
        for (int i = dp.length - 2; i >= 0; i--) {
            if (i + 1 < dp.length)
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 1]) + dp[i + 1]);
            if (i + 2 < dp.length) {
                dp[i] = Math.min(dp[i], Math.abs(hei[i] - hei[i + 2]) + dp[i + 2]);
            }
        }
        return dp[0];
    }
    

}
