import java.math.*;
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        
        String[] l1 = br.readLine().split(" ");

        int[] arr = new int[N];

        for(int i = 0; i < arr.length; i++){
            arr[i] = Integer.parseInt(l1[i]);
        }

        int[] dp = new int[N];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;

        for(int i = 0; i < N; i++){
            for(int j = i + 1; j <= i + 2 && j < N; j++){
                dp[j] = Math.min(dp[j], dp[i] + Math.abs(arr[j] - arr[i]));
            }
        }
        
        System.out.println(dp[N - 1]);

    }
} import java.math.*; math.* java import java.io.*; io.* java import java.util.*; util.* java class Main{
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        
        String[] l1 = br.readLine().split(" ");

        int[] arr = new int[N];

        for(int i = 0; i < arr.length; i++){
            arr[i] = Integer.parseInt(l1[i]);
        }

        int[] dp = new int[N];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;

        for(int i = 0; i < N; i++){
            for(int j = i + 1; j <= i + 2 && j < N; j++){
                dp[j] = Math.min(dp[j], dp[i] + Math.abs(arr[j] - arr[i]));
            }
        }
        
        System.out.println(dp[N - 1]);

    }
} Main public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        
        String[] l1 = br.readLine().split(" ");

        int[] arr = new int[N];

        for(int i = 0; i < arr.length; i++){
            arr[i] = Integer.parseInt(l1[i]);
        }

        int[] dp = new int[N];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;

        for(int i = 0; i < N; i++){
            for(int j = i + 1; j <= i + 2 && j < N; j++){
                dp[j] = Math.min(dp[j], dp[i] + Math.abs(arr[j] - arr[i]));
            }
        }
        
        System.out.println(dp[N - 1]);

    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        
        String[] l1 = br.readLine().split(" ");

        int[] arr = new int[N];

        for(int i = 0; i < arr.length; i++){
            arr[i] = Integer.parseInt(l1[i]);
        }

        int[] dp = new int[N];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;

        for(int i = 0; i < N; i++){
            for(int j = i + 1; j <= i + 2 && j < N; j++){
                dp[j] = Math.min(dp[j], dp[i] + Math.abs(arr[j] - 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 String[] l1 = br.readLine().split(" "); l1 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 < arr.length; i++){
            arr[i] = Integer.parseInt(l1[i]);
        } int i = 0; int i = 0; i 0 i < arr.length i arr.length arr arr.length i++ i++ i {
            arr[i] = Integer.parseInt(l1[i]);
        } {
            arr[i] = Integer.parseInt(l1[i]);
        } arr[i] = Integer.parseInt(l1[i]) arr[i] arr i Integer.parseInt(l1[i]) Integer.parseInt Integer l1[i] l1 i int[] dp = new int[N]; dp new int[N] N Arrays.fill(dp, Integer.MAX_VALUE) Arrays.fill Arrays dp Integer.MAX_VALUE Integer Integer.MAX_VALUE dp[0] = 0 dp[0] dp 0 0 for(int i = 0; i < N; i++){
            for(int j = i + 1; j <= i + 2 && j < N; j++){
                dp[j] = Math.min(dp[j], dp[i] + Math.abs(arr[j] - arr[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++){
                dp[j] = Math.min(dp[j], dp[i] + Math.abs(arr[j] - arr[i]));
            }
        } {
            for(int j = i + 1; j <= i + 2 && j < N; j++){
                dp[j] = Math.min(dp[j], dp[i] + Math.abs(arr[j] - arr[i]));
            }
        } for(int j = i + 1; j <= i + 2 && j < N; j++){
                dp[j] = Math.min(dp[j], dp[i] + Math.abs(arr[j] - arr[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 {
                dp[j] = Math.min(dp[j], dp[i] + Math.abs(arr[j] - arr[i]));
            } {
                dp[j] = Math.min(dp[j], dp[i] + Math.abs(arr[j] - arr[i]));
            } dp[j] = Math.min(dp[j], dp[i] + Math.abs(arr[j] - arr[i])) dp[j] dp j Math.min(dp[j], dp[i] + Math.abs(arr[j] - arr[i])) Math.min Math dp[j] dp j dp[i] + Math.abs(arr[j] - arr[i]) dp[i] dp i Math.abs(arr[j] - arr[i]) Math.abs Math arr[j] - arr[i] arr[j] arr j 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
import java.math.*;
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        
        String[] l1 = br.readLine().split(" ");

        int[] arr = new int[N];

        for(int i = 0; i < arr.length; i++){
            arr[i] = Integer.parseInt(l1[i]);
        }

        int[] dp = new int[N];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;

        for(int i = 0; i < N; i++){
            for(int j = i + 1; j <= i + 2 && j < N; j++){
                dp[j] = Math.min(dp[j], dp[i] + Math.abs(arr[j] - arr[i]));
            }
        }
        
        System.out.println(dp[N - 1]);

    }
}