/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		BufferedReader br=  new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		StringBuilder str = new StringBuilder();
		String[] in = br.readLine().split(" ");
		int[] arr = new int[n];
// 		while(t--!=0){
		    
// 		}
        for(int i=0;i<n;i++){
            arr[i] = Integer.parseInt(in[i]);
        }
        int curr = n-1;
        int ans = 0;
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = dp[0]+Math.abs(arr[0]-arr[1]);
        for(int i=2;i<n;i++){
            dp[i] = Math.min(dp[i-2]+Math.abs(arr[i-2]-arr[i]),dp[i-1]+Math.abs(arr[i-1]-arr[i]));
        }
        System.out.println(dp[n-1]);
	}
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		BufferedReader br=  new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		StringBuilder str = new StringBuilder();
		String[] in = br.readLine().split(" ");
		int[] arr = new int[n];
// 		while(t--!=0){
		    
// 		}
        for(int i=0;i<n;i++){
            arr[i] = Integer.parseInt(in[i]);
        }
        int curr = n-1;
        int ans = 0;
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = dp[0]+Math.abs(arr[0]-arr[1]);
        for(int i=2;i<n;i++){
            dp[i] = Math.min(dp[i-2]+Math.abs(arr[i-2]-arr[i]),dp[i-1]+Math.abs(arr[i-1]-arr[i]));
        }
        System.out.println(dp[n-1]);
	}
} Main public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		BufferedReader br=  new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		StringBuilder str = new StringBuilder();
		String[] in = br.readLine().split(" ");
		int[] arr = new int[n];
// 		while(t--!=0){
		    
// 		}
        for(int i=0;i<n;i++){
            arr[i] = Integer.parseInt(in[i]);
        }
        int curr = n-1;
        int ans = 0;
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = dp[0]+Math.abs(arr[0]-arr[1]);
        for(int i=2;i<n;i++){
            dp[i] = Math.min(dp[i-2]+Math.abs(arr[i-2]-arr[i]),dp[i-1]+Math.abs(arr[i-1]-arr[i]));
        }
        System.out.println(dp[n-1]);
	} main {
		// your code goes here
		BufferedReader br=  new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		StringBuilder str = new StringBuilder();
		String[] in = br.readLine().split(" ");
		int[] arr = new int[n];
// 		while(t--!=0){
		    
// 		}
        for(int i=0;i<n;i++){
            arr[i] = Integer.parseInt(in[i]);
        }
        int curr = n-1;
        int ans = 0;
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = dp[0]+Math.abs(arr[0]-arr[1]);
        for(int i=2;i<n;i++){
            dp[i] = Math.min(dp[i-2]+Math.abs(arr[i-2]-arr[i]),dp[i-1]+Math.abs(arr[i-1]-arr[i]));
        }
        System.out.println(dp[n-1]);
	} BufferedReader br=  new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int n = Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br StringBuilder str = new StringBuilder(); str new StringBuilder() String[] in = br.readLine().split(" "); in br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int[] arr = new int[n]; arr new int[n] n for(int i=0;i<n;i++){
            arr[i] = Integer.parseInt(in[i]);
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            arr[i] = Integer.parseInt(in[i]);
        } {
            arr[i] = Integer.parseInt(in[i]);
        } arr[i] = Integer.parseInt(in[i]) arr[i] arr i Integer.parseInt(in[i]) Integer.parseInt Integer in[i] in i int curr = n-1; curr n-1 n 1 int ans = 0; ans 0 int[] dp = new int[n]; dp new int[n] n dp[0] = 0 dp[0] dp 0 0 dp[1] = dp[0]+Math.abs(arr[0]-arr[1]) dp[1] dp 1 dp[0]+Math.abs(arr[0]-arr[1]) dp[0] dp 0 Math.abs(arr[0]-arr[1]) Math.abs Math arr[0]-arr[1] arr[0] arr 0 arr[1] arr 1 for(int i=2;i<n;i++){
            dp[i] = Math.min(dp[i-2]+Math.abs(arr[i-2]-arr[i]),dp[i-1]+Math.abs(arr[i-1]-arr[i]));
        } int i=2; int i=2; i 2 i<n i n i++ i++ i {
            dp[i] = Math.min(dp[i-2]+Math.abs(arr[i-2]-arr[i]),dp[i-1]+Math.abs(arr[i-1]-arr[i]));
        } {
            dp[i] = Math.min(dp[i-2]+Math.abs(arr[i-2]-arr[i]),dp[i-1]+Math.abs(arr[i-1]-arr[i]));
        } dp[i] = Math.min(dp[i-2]+Math.abs(arr[i-2]-arr[i]),dp[i-1]+Math.abs(arr[i-1]-arr[i])) dp[i] dp i Math.min(dp[i-2]+Math.abs(arr[i-2]-arr[i]),dp[i-1]+Math.abs(arr[i-1]-arr[i])) Math.min Math dp[i-2]+Math.abs(arr[i-2]-arr[i]) dp[i-2] dp i-2 i 2 Math.abs(arr[i-2]-arr[i]) Math.abs Math arr[i-2]-arr[i] arr[i-2] arr i-2 i 2 arr[i] arr i dp[i-1]+Math.abs(arr[i-1]-arr[i]) dp[i-1] dp i-1 i 1 Math.abs(arr[i-1]-arr[i]) Math.abs Math arr[i-1]-arr[i] arr[i-1] arr i-1 i 1 arr[i] arr i 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 class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		BufferedReader br=  new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		StringBuilder str = new StringBuilder();
		String[] in = br.readLine().split(" ");
		int[] arr = new int[n];
// 		while(t--!=0){
		    
// 		}
        for(int i=0;i<n;i++){
            arr[i] = Integer.parseInt(in[i]);
        }
        int curr = n-1;
        int ans = 0;
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = dp[0]+Math.abs(arr[0]-arr[1]);
        for(int i=2;i<n;i++){
            dp[i] = Math.min(dp[i-2]+Math.abs(arr[i-2]-arr[i]),dp[i-1]+Math.abs(arr[i-1]-arr[i]));
        }
        System.out.println(dp[n-1]);
	}
} public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		BufferedReader br=  new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		StringBuilder str = new StringBuilder();
		String[] in = br.readLine().split(" ");
		int[] arr = new int[n];
// 		while(t--!=0){
		    
// 		}
        for(int i=0;i<n;i++){
            arr[i] = Integer.parseInt(in[i]);
        }
        int curr = n-1;
        int ans = 0;
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = dp[0]+Math.abs(arr[0]-arr[1]);
        for(int i=2;i<n;i++){
            dp[i] = Math.min(dp[i-2]+Math.abs(arr[i-2]-arr[i]),dp[i-1]+Math.abs(arr[i-1]-arr[i]));
        }
        System.out.println(dp[n-1]);
	}
} Main
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		BufferedReader br=  new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		StringBuilder str = new StringBuilder();
		String[] in = br.readLine().split(" ");
		int[] arr = new int[n];
// 		while(t--!=0){
		    
// 		}
        for(int i=0;i<n;i++){
            arr[i] = Integer.parseInt(in[i]);
        }
        int curr = n-1;
        int ans = 0;
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = dp[0]+Math.abs(arr[0]-arr[1]);
        for(int i=2;i<n;i++){
            dp[i] = Math.min(dp[i-2]+Math.abs(arr[i-2]-arr[i]),dp[i-1]+Math.abs(arr[i-1]-arr[i]));
        }
        System.out.println(dp[n-1]);
	}
}
