import java.util.Scanner;

class FrogJump {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        // Read number of stones
        int n = sc.nextInt();
        int[] heights = new int[n + 1]; // heights array, 1-based indexing
        
        // Read heights of the stones
        for (int i = 1; i <= n; i++) {
            heights[i] = sc.nextInt();
        }
        
        // DP array to store minimum costs
        int[] dp = new int[n + 1];
        
        // Base cases
        dp[1] = 0; // Cost to reach the first stone is 0
        if (n > 1) {
            dp[2] = Math.abs(heights[2] - heights[1]); // Cost to jump to the second stone
        }
        
        // Fill the dp array
        for (int i = 3; i <= n; i++) {
            int jumpFromOneBack = dp[i - 1] + Math.abs(heights[i] - heights[i - 1]);
            int jumpFromTwoBack = dp[i - 2] + Math.abs(heights[i] - heights[i - 2]);
            dp[i] = Math.min(jumpFromOneBack, jumpFromTwoBack);
        }
        
        // The answer is the minimum cost to reach the last stone
        System.out.println(dp[n]);
        
        sc.close(); // Close the scanner
    }
}
