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

public class Main {
    public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n =scn.nextInt();
		int []h = new int[n];
		for(int i=0;i<n;i++)
		{
			h[i]=scn.nextInt();
		}
		int []res = new int[n];
		Arrays.fill(res, Integer.MAX_VALUE);
		res[0]=0;
		for(int i=0;i<n;i++)
		{
			for(int j =i+1;j<=i+2&&j<n;j++)
			{
              if(res[i]!=Integer.MAX_VALUE)
				res[j]=Math.min(res[j], Math.abs(h[j]-h[i])+res[i]);
			}
		}
		System.out.println(res[n-1]);
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n =scn.nextInt();
		int []h = new int[n];
		for(int i=0;i<n;i++)
		{
			h[i]=scn.nextInt();
		}
		int []res = new int[n];
		Arrays.fill(res, Integer.MAX_VALUE);
		res[0]=0;
		for(int i=0;i<n;i++)
		{
			for(int j =i+1;j<=i+2&&j<n;j++)
			{
              if(res[i]!=Integer.MAX_VALUE)
				res[j]=Math.min(res[j], Math.abs(h[j]-h[i])+res[i]);
			}
		}
		System.out.println(res[n-1]);
	}
} Main public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n =scn.nextInt();
		int []h = new int[n];
		for(int i=0;i<n;i++)
		{
			h[i]=scn.nextInt();
		}
		int []res = new int[n];
		Arrays.fill(res, Integer.MAX_VALUE);
		res[0]=0;
		for(int i=0;i<n;i++)
		{
			for(int j =i+1;j<=i+2&&j<n;j++)
			{
              if(res[i]!=Integer.MAX_VALUE)
				res[j]=Math.min(res[j], Math.abs(h[j]-h[i])+res[i]);
			}
		}
		System.out.println(res[n-1]);
	} main {
		Scanner scn = new Scanner(System.in);
		int n =scn.nextInt();
		int []h = new int[n];
		for(int i=0;i<n;i++)
		{
			h[i]=scn.nextInt();
		}
		int []res = new int[n];
		Arrays.fill(res, Integer.MAX_VALUE);
		res[0]=0;
		for(int i=0;i<n;i++)
		{
			for(int j =i+1;j<=i+2&&j<n;j++)
			{
              if(res[i]!=Integer.MAX_VALUE)
				res[j]=Math.min(res[j], Math.abs(h[j]-h[i])+res[i]);
			}
		}
		System.out.println(res[n-1]);
	} Scanner scn = new Scanner(System.in); scn new Scanner(System.in) int n =scn.nextInt(); n scn.nextInt() scn.nextInt scn int []h = new int[n]; h new int[n] n for(int i=0;i<n;i++)
		{
			h[i]=scn.nextInt();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			h[i]=scn.nextInt();
		} {
			h[i]=scn.nextInt();
		} h[i]=scn.nextInt() h[i] h i scn.nextInt() scn.nextInt scn int []res = new int[n]; res new int[n] n Arrays.fill(res, Integer.MAX_VALUE) Arrays.fill Arrays res Integer.MAX_VALUE Integer Integer.MAX_VALUE res[0]=0 res[0] res 0 0 for(int i=0;i<n;i++)
		{
			for(int j =i+1;j<=i+2&&j<n;j++)
			{
              if(res[i]!=Integer.MAX_VALUE)
				res[j]=Math.min(res[j], Math.abs(h[j]-h[i])+res[i]);
			}
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			for(int j =i+1;j<=i+2&&j<n;j++)
			{
              if(res[i]!=Integer.MAX_VALUE)
				res[j]=Math.min(res[j], Math.abs(h[j]-h[i])+res[i]);
			}
		} {
			for(int j =i+1;j<=i+2&&j<n;j++)
			{
              if(res[i]!=Integer.MAX_VALUE)
				res[j]=Math.min(res[j], Math.abs(h[j]-h[i])+res[i]);
			}
		} for(int j =i+1;j<=i+2&&j<n;j++)
			{
              if(res[i]!=Integer.MAX_VALUE)
				res[j]=Math.min(res[j], Math.abs(h[j]-h[i])+res[i]);
			} int j =i+1; int j =i+1; j i+1 i 1 j<=i+2&&j<n j<=i+2 j i+2 i 2 j<n j n j++ j++ j {
              if(res[i]!=Integer.MAX_VALUE)
				res[j]=Math.min(res[j], Math.abs(h[j]-h[i])+res[i]);
			} {
              if(res[i]!=Integer.MAX_VALUE)
				res[j]=Math.min(res[j], Math.abs(h[j]-h[i])+res[i]);
			} if(res[i]!=Integer.MAX_VALUE)
				res[j]=Math.min(res[j], Math.abs(h[j]-h[i])+res[i]); res[i]!=Integer.MAX_VALUE res[i] res i Integer.MAX_VALUE Integer Integer.MAX_VALUE res[j]=Math.min(res[j], Math.abs(h[j]-h[i])+res[i]) res[j] res j Math.min(res[j], Math.abs(h[j]-h[i])+res[i]) Math.min Math res[j] res j Math.abs(h[j]-h[i])+res[i] Math.abs(h[j]-h[i]) Math.abs Math h[j]-h[i] h[j] h j h[i] h i res[i] res i System.out.println(res[n-1]) System.out.println System.out System System.out res[n-1] res n-1 n 1 String[] args args public class Main {
    public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n =scn.nextInt();
		int []h = new int[n];
		for(int i=0;i<n;i++)
		{
			h[i]=scn.nextInt();
		}
		int []res = new int[n];
		Arrays.fill(res, Integer.MAX_VALUE);
		res[0]=0;
		for(int i=0;i<n;i++)
		{
			for(int j =i+1;j<=i+2&&j<n;j++)
			{
              if(res[i]!=Integer.MAX_VALUE)
				res[j]=Math.min(res[j], Math.abs(h[j]-h[i])+res[i]);
			}
		}
		System.out.println(res[n-1]);
	}
} public class Main {
    public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n =scn.nextInt();
		int []h = new int[n];
		for(int i=0;i<n;i++)
		{
			h[i]=scn.nextInt();
		}
		int []res = new int[n];
		Arrays.fill(res, Integer.MAX_VALUE);
		res[0]=0;
		for(int i=0;i<n;i++)
		{
			for(int j =i+1;j<=i+2&&j<n;j++)
			{
              if(res[i]!=Integer.MAX_VALUE)
				res[j]=Math.min(res[j], Math.abs(h[j]-h[i])+res[i]);
			}
		}
		System.out.println(res[n-1]);
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n =scn.nextInt();
		int []h = new int[n];
		for(int i=0;i<n;i++)
		{
			h[i]=scn.nextInt();
		}
		int []res = new int[n];
		Arrays.fill(res, Integer.MAX_VALUE);
		res[0]=0;
		for(int i=0;i<n;i++)
		{
			for(int j =i+1;j<=i+2&&j<n;j++)
			{
              if(res[i]!=Integer.MAX_VALUE)
				res[j]=Math.min(res[j], Math.abs(h[j]-h[i])+res[i]);
			}
		}
		System.out.println(res[n-1]);
	}
}
