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

public class Main {

    public static int minCost(int[] h, int i, int[] dp) {

        if (i == 0) {
            return 0;
        }
        if (i == 1) {
            return Math.abs(h[0] - h[1]);
        }
        if(dp[i] !=-1){
            return dp[i];
        }


        return dp[i] = Math.min(minCost(h, i - 1,dp) + Math.abs(h[i] - h[i - 1]), minCost(h, i - 2,dp) + Math.abs(h[i] - h[i - 2]));
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        try {
            int size = scanner.nextInt();
            int[] nums = new int[size];
            for (int i = 0; i < nums.length; i++) {
                nums[i] = scanner.nextInt();
            }
            int[] dp = new int[size];
            Arrays.fill(dp, -1);
            System.out.println(minCost(nums, size - 1, dp));
        } finally {
            scanner.close();
        }
    }
}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz