

import java.util.*;



import java.io.*;
public class Main {

	public static void main(String[] args) {
	FastScanner sc=new FastScanner();
	int n=sc.nextInt();
	int a[]=sc.readArray(n);
	if(n<=1)
		System.out.println("0");
	else {
		int dp[]=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(a[1]-a[0]);
		
		for(int i=2;i<n;i++)
		{
			dp[i]=Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]), dp[i-2]+Math.abs(a[i]-a[i-2]));
		}
		System.out.println(dp[n-1]);
		
	}

	}
	static class FastScanner{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		int [] readArray(int n) {
			int a[]=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		}
		
		
	}
	

} import java.util.*; util.* java import java.io.*; io.* java public class Main {

	public static void main(String[] args) {
	FastScanner sc=new FastScanner();
	int n=sc.nextInt();
	int a[]=sc.readArray(n);
	if(n<=1)
		System.out.println("0");
	else {
		int dp[]=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(a[1]-a[0]);
		
		for(int i=2;i<n;i++)
		{
			dp[i]=Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]), dp[i-2]+Math.abs(a[i]-a[i-2]));
		}
		System.out.println(dp[n-1]);
		
	}

	}
	static class FastScanner{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		int [] readArray(int n) {
			int a[]=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		}
		
		
	}
	

} Main public static void main(String[] args) {
	FastScanner sc=new FastScanner();
	int n=sc.nextInt();
	int a[]=sc.readArray(n);
	if(n<=1)
		System.out.println("0");
	else {
		int dp[]=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(a[1]-a[0]);
		
		for(int i=2;i<n;i++)
		{
			dp[i]=Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]), dp[i-2]+Math.abs(a[i]-a[i-2]));
		}
		System.out.println(dp[n-1]);
		
	}

	} main {
	FastScanner sc=new FastScanner();
	int n=sc.nextInt();
	int a[]=sc.readArray(n);
	if(n<=1)
		System.out.println("0");
	else {
		int dp[]=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(a[1]-a[0]);
		
		for(int i=2;i<n;i++)
		{
			dp[i]=Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]), dp[i-2]+Math.abs(a[i]-a[i-2]));
		}
		System.out.println(dp[n-1]);
		
	}

	} FastScanner sc=new FastScanner(); sc new FastScanner() int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int a[]=sc.readArray(n); a sc.readArray(n) sc.readArray sc n if(n<=1)
		System.out.println("0");
	else {
		int dp[]=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(a[1]-a[0]);
		
		for(int i=2;i<n;i++)
		{
			dp[i]=Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]), dp[i-2]+Math.abs(a[i]-a[i-2]));
		}
		System.out.println(dp[n-1]);
		
	} n<=1 n 1 System.out.println("0") System.out.println System.out System System.out "0" {
		int dp[]=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(a[1]-a[0]);
		
		for(int i=2;i<n;i++)
		{
			dp[i]=Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]), dp[i-2]+Math.abs(a[i]-a[i-2]));
		}
		System.out.println(dp[n-1]);
		
	} int dp[]=new int[n]; dp new int[n] n dp[0]=0 dp[0] dp 0 0 dp[1]=Math.abs(a[1]-a[0]) dp[1] dp 1 Math.abs(a[1]-a[0]) Math.abs Math a[1]-a[0] a[1] a 1 a[0] a 0 for(int i=2;i<n;i++)
		{
			dp[i]=Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]), dp[i-2]+Math.abs(a[i]-a[i-2]));
		} int i=2; int i=2; i 2 i<n i n i++ i++ i {
			dp[i]=Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]), dp[i-2]+Math.abs(a[i]-a[i-2]));
		} {
			dp[i]=Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]), dp[i-2]+Math.abs(a[i]-a[i-2]));
		} dp[i]=Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]), dp[i-2]+Math.abs(a[i]-a[i-2])) dp[i] dp i Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]), dp[i-2]+Math.abs(a[i]-a[i-2])) Math.min Math dp[i-1]+Math.abs(a[i]-a[i-1]) dp[i-1] dp i-1 i 1 Math.abs(a[i]-a[i-1]) Math.abs Math a[i]-a[i-1] a[i] a i a[i-1] a i-1 i 1 dp[i-2]+Math.abs(a[i]-a[i-2]) dp[i-2] dp i-2 i 2 Math.abs(a[i]-a[i-2]) Math.abs Math a[i]-a[i-2] a[i] a i a[i-2] a i-2 i 2 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 static class FastScanner{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		int [] readArray(int n) {
			int a[]=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		}
		
		
	} FastScanner BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringTokenizer st=new StringTokenizer(""); st new StringTokenizer("") String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		} next {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		} while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				} !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				} IOException e {
					e.printStackTrace();
				} e.printStackTrace() e.printStackTrace e {
					st=new StringTokenizer(br.readLine());
				} st=new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt() {
			return Integer.parseInt(next());
		} nextInt {
			return Integer.parseInt(next());
		} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong() {
			return Long.parseLong(next());
		} nextLong {
			return Long.parseLong(next());
		} return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next int [] readArray(int n) {
			int a[]=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		} readArray {
			int a[]=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		} int a[]=new int[n]; a new int[n] n for(int i=0;i<n;i++) a[i]=nextInt(); int i=0; int i=0; i 0 i<n i n i++ i++ i a[i]=nextInt(); a[i]=nextInt() a[i] a i nextInt() nextInt return a; a int n n public class Main {

	public static void main(String[] args) {
	FastScanner sc=new FastScanner();
	int n=sc.nextInt();
	int a[]=sc.readArray(n);
	if(n<=1)
		System.out.println("0");
	else {
		int dp[]=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(a[1]-a[0]);
		
		for(int i=2;i<n;i++)
		{
			dp[i]=Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]), dp[i-2]+Math.abs(a[i]-a[i-2]));
		}
		System.out.println(dp[n-1]);
		
	}

	}
	static class FastScanner{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		int [] readArray(int n) {
			int a[]=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		}
		
		
	}
	

} public class Main {

	public static void main(String[] args) {
	FastScanner sc=new FastScanner();
	int n=sc.nextInt();
	int a[]=sc.readArray(n);
	if(n<=1)
		System.out.println("0");
	else {
		int dp[]=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(a[1]-a[0]);
		
		for(int i=2;i<n;i++)
		{
			dp[i]=Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]), dp[i-2]+Math.abs(a[i]-a[i-2]));
		}
		System.out.println(dp[n-1]);
		
	}

	}
	static class FastScanner{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		int [] readArray(int n) {
			int a[]=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		}
		
		
	}
	

} Main


import java.util.*;



import java.io.*;
public class Main {

	public static void main(String[] args) {
	FastScanner sc=new FastScanner();
	int n=sc.nextInt();
	int a[]=sc.readArray(n);
	if(n<=1)
		System.out.println("0");
	else {
		int dp[]=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(a[1]-a[0]);
		
		for(int i=2;i<n;i++)
		{
			dp[i]=Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]), dp[i-2]+Math.abs(a[i]-a[i-2]));
		}
		System.out.println(dp[n-1]);
		
	}

	}
	static class FastScanner{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		int [] readArray(int n) {
			int a[]=new int[n];
			for(int i=0;i<n;i++) a[i]=nextInt();
			return a;
		}
		
		
	}
	

}
