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

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++){
		    arr[i] = scn.nextInt();
		}
      	int[] mem = new int[arr.length];
      	Arrays.fill(mem,-1);
		int ans = solution(0,arr,mem);
        System.out.println(ans);
	}
	
	public static int solution(int idx,int[] arr,int[] mem){
	    if(idx==arr.length-1)return mem[idx]=0;
      	if(mem[idx]!=-1)return mem[idx];
	    int o1 = idx+1<arr.length?solution(idx+1,arr,mem)+Math.abs(arr[idx+1]-arr[idx]):1000000;
	    int o2 = idx+2<arr.length?solution(idx+2,arr,mem)+Math.abs(arr[idx+2]-arr[idx]):1000000;
	    return mem[idx]=Math.min(o1,o2);
	}
} 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
	{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++){
		    arr[i] = scn.nextInt();
		}
      	int[] mem = new int[arr.length];
      	Arrays.fill(mem,-1);
		int ans = solution(0,arr,mem);
        System.out.println(ans);
	}
	
	public static int solution(int idx,int[] arr,int[] mem){
	    if(idx==arr.length-1)return mem[idx]=0;
      	if(mem[idx]!=-1)return mem[idx];
	    int o1 = idx+1<arr.length?solution(idx+1,arr,mem)+Math.abs(arr[idx+1]-arr[idx]):1000000;
	    int o2 = idx+2<arr.length?solution(idx+2,arr,mem)+Math.abs(arr[idx+2]-arr[idx]):1000000;
	    return mem[idx]=Math.min(o1,o2);
	}
} Main public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++){
		    arr[i] = scn.nextInt();
		}
      	int[] mem = new int[arr.length];
      	Arrays.fill(mem,-1);
		int ans = solution(0,arr,mem);
        System.out.println(ans);
	} main {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++){
		    arr[i] = scn.nextInt();
		}
      	int[] mem = new int[arr.length];
      	Arrays.fill(mem,-1);
		int ans = solution(0,arr,mem);
        System.out.println(ans);
	} Scanner scn = new Scanner(System.in); scn new Scanner(System.in) int n = scn.nextInt(); n scn.nextInt() scn.nextInt scn int[] arr = new int[n]; arr new int[n] n for(int i=0;i<n;i++){
		    arr[i] = scn.nextInt();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
		    arr[i] = scn.nextInt();
		} {
		    arr[i] = scn.nextInt();
		} arr[i] = scn.nextInt() arr[i] arr i scn.nextInt() scn.nextInt scn int[] mem = new int[arr.length]; mem new int[arr.length] arr.length arr arr.length Arrays.fill(mem,-1) Arrays.fill Arrays mem -1 1 int ans = solution(0,arr,mem); ans solution(0,arr,mem) solution 0 arr mem System.out.println(ans) System.out.println System.out System System.out ans String[] args args public static int solution(int idx,int[] arr,int[] mem){
	    if(idx==arr.length-1)return mem[idx]=0;
      	if(mem[idx]!=-1)return mem[idx];
	    int o1 = idx+1<arr.length?solution(idx+1,arr,mem)+Math.abs(arr[idx+1]-arr[idx]):1000000;
	    int o2 = idx+2<arr.length?solution(idx+2,arr,mem)+Math.abs(arr[idx+2]-arr[idx]):1000000;
	    return mem[idx]=Math.min(o1,o2);
	} solution {
	    if(idx==arr.length-1)return mem[idx]=0;
      	if(mem[idx]!=-1)return mem[idx];
	    int o1 = idx+1<arr.length?solution(idx+1,arr,mem)+Math.abs(arr[idx+1]-arr[idx]):1000000;
	    int o2 = idx+2<arr.length?solution(idx+2,arr,mem)+Math.abs(arr[idx+2]-arr[idx]):1000000;
	    return mem[idx]=Math.min(o1,o2);
	} if(idx==arr.length-1)return mem[idx]=0; idx==arr.length-1 idx arr.length-1 arr.length arr arr.length 1 return mem[idx]=0; mem[idx]=0 mem[idx] mem idx 0 if(mem[idx]!=-1)return mem[idx]; mem[idx]!=-1 mem[idx] mem idx -1 1 return mem[idx]; mem[idx] mem idx int o1 = idx+1<arr.length?solution(idx+1,arr,mem)+Math.abs(arr[idx+1]-arr[idx]):1000000; o1 idx+1<arr.length?solution(idx+1,arr,mem)+Math.abs(arr[idx+1]-arr[idx]):1000000 idx+1<arr.length idx+1 idx 1 arr.length arr arr.length solution(idx+1,arr,mem)+Math.abs(arr[idx+1]-arr[idx]) solution(idx+1,arr,mem) solution idx+1 idx 1 arr mem Math.abs(arr[idx+1]-arr[idx]) Math.abs Math arr[idx+1]-arr[idx] arr[idx+1] arr idx+1 idx 1 arr[idx] arr idx 1000000 int o2 = idx+2<arr.length?solution(idx+2,arr,mem)+Math.abs(arr[idx+2]-arr[idx]):1000000; o2 idx+2<arr.length?solution(idx+2,arr,mem)+Math.abs(arr[idx+2]-arr[idx]):1000000 idx+2<arr.length idx+2 idx 2 arr.length arr arr.length solution(idx+2,arr,mem)+Math.abs(arr[idx+2]-arr[idx]) solution(idx+2,arr,mem) solution idx+2 idx 2 arr mem Math.abs(arr[idx+2]-arr[idx]) Math.abs Math arr[idx+2]-arr[idx] arr[idx+2] arr idx+2 idx 2 arr[idx] arr idx 1000000 return mem[idx]=Math.min(o1,o2); mem[idx]=Math.min(o1,o2) mem[idx] mem idx Math.min(o1,o2) Math.min Math o1 o2 int idx idx int[] arr arr int[] mem mem public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++){
		    arr[i] = scn.nextInt();
		}
      	int[] mem = new int[arr.length];
      	Arrays.fill(mem,-1);
		int ans = solution(0,arr,mem);
        System.out.println(ans);
	}
	
	public static int solution(int idx,int[] arr,int[] mem){
	    if(idx==arr.length-1)return mem[idx]=0;
      	if(mem[idx]!=-1)return mem[idx];
	    int o1 = idx+1<arr.length?solution(idx+1,arr,mem)+Math.abs(arr[idx+1]-arr[idx]):1000000;
	    int o2 = idx+2<arr.length?solution(idx+2,arr,mem)+Math.abs(arr[idx+2]-arr[idx]):1000000;
	    return mem[idx]=Math.min(o1,o2);
	}
} public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++){
		    arr[i] = scn.nextInt();
		}
      	int[] mem = new int[arr.length];
      	Arrays.fill(mem,-1);
		int ans = solution(0,arr,mem);
        System.out.println(ans);
	}
	
	public static int solution(int idx,int[] arr,int[] mem){
	    if(idx==arr.length-1)return mem[idx]=0;
      	if(mem[idx]!=-1)return mem[idx];
	    int o1 = idx+1<arr.length?solution(idx+1,arr,mem)+Math.abs(arr[idx+1]-arr[idx]):1000000;
	    int o2 = idx+2<arr.length?solution(idx+2,arr,mem)+Math.abs(arr[idx+2]-arr[idx]):1000000;
	    return mem[idx]=Math.min(o1,o2);
	}
} Main
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++){
		    arr[i] = scn.nextInt();
		}
      	int[] mem = new int[arr.length];
      	Arrays.fill(mem,-1);
		int ans = solution(0,arr,mem);
        System.out.println(ans);
	}
	
	public static int solution(int idx,int[] arr,int[] mem){
	    if(idx==arr.length-1)return mem[idx]=0;
      	if(mem[idx]!=-1)return mem[idx];
	    int o1 = idx+1<arr.length?solution(idx+1,arr,mem)+Math.abs(arr[idx+1]-arr[idx]):1000000;
	    int o2 = idx+2<arr.length?solution(idx+2,arr,mem)+Math.abs(arr[idx+2]-arr[idx]):1000000;
	    return mem[idx]=Math.min(o1,o2);
	}
}
