import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int arr[] = new int[x];
        for (int i = 0; i < x; i++)
            arr[i] = sc.nextInt();
        int dp[] = new int[x];
        if(x==1)
            System.out.println(arr[0]);
        for (int i = 1; i < x; i++) {
            int abs1 = Math.abs(arr[i] - arr[i - 1]);
            if (i == 1) {
                int abs = abs1;
                dp[i] = abs;
            } else {
                dp[i] = Math.min(abs1+dp[i-1], Math.abs(arr[i] - arr[i - 2])+dp[i-2]);
            }
        }
        System.out.println(dp[x - 1]);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int arr[] = new int[x];
        for (int i = 0; i < x; i++)
            arr[i] = sc.nextInt();
        int dp[] = new int[x];
        if(x==1)
            System.out.println(arr[0]);
        for (int i = 1; i < x; i++) {
            int abs1 = Math.abs(arr[i] - arr[i - 1]);
            if (i == 1) {
                int abs = abs1;
                dp[i] = abs;
            } else {
                dp[i] = Math.min(abs1+dp[i-1], Math.abs(arr[i] - arr[i - 2])+dp[i-2]);
            }
        }
        System.out.println(dp[x - 1]);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int arr[] = new int[x];
        for (int i = 0; i < x; i++)
            arr[i] = sc.nextInt();
        int dp[] = new int[x];
        if(x==1)
            System.out.println(arr[0]);
        for (int i = 1; i < x; i++) {
            int abs1 = Math.abs(arr[i] - arr[i - 1]);
            if (i == 1) {
                int abs = abs1;
                dp[i] = abs;
            } else {
                dp[i] = Math.min(abs1+dp[i-1], Math.abs(arr[i] - arr[i - 2])+dp[i-2]);
            }
        }
        System.out.println(dp[x - 1]);
    } main {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int arr[] = new int[x];
        for (int i = 0; i < x; i++)
            arr[i] = sc.nextInt();
        int dp[] = new int[x];
        if(x==1)
            System.out.println(arr[0]);
        for (int i = 1; i < x; i++) {
            int abs1 = Math.abs(arr[i] - arr[i - 1]);
            if (i == 1) {
                int abs = abs1;
                dp[i] = abs;
            } else {
                dp[i] = Math.min(abs1+dp[i-1], Math.abs(arr[i] - arr[i - 2])+dp[i-2]);
            }
        }
        System.out.println(dp[x - 1]);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int arr[] = new int[x]; arr new int[x] x for (int i = 0; i < x; i++)
            arr[i] = sc.nextInt(); int i = 0; int i = 0; i 0 i < x i x i++ i++ i arr[i] = sc.nextInt(); arr[i] = sc.nextInt() arr[i] arr i sc.nextInt() sc.nextInt sc int dp[] = new int[x]; dp new int[x] x if(x==1)
            System.out.println(arr[0]); x==1 x 1 System.out.println(arr[0]) System.out.println System.out System System.out arr[0] arr 0 for (int i = 1; i < x; i++) {
            int abs1 = Math.abs(arr[i] - arr[i - 1]);
            if (i == 1) {
                int abs = abs1;
                dp[i] = abs;
            } else {
                dp[i] = Math.min(abs1+dp[i-1], Math.abs(arr[i] - arr[i - 2])+dp[i-2]);
            }
        } int i = 1; int i = 1; i 1 i < x i x i++ i++ i {
            int abs1 = Math.abs(arr[i] - arr[i - 1]);
            if (i == 1) {
                int abs = abs1;
                dp[i] = abs;
            } else {
                dp[i] = Math.min(abs1+dp[i-1], Math.abs(arr[i] - arr[i - 2])+dp[i-2]);
            }
        } {
            int abs1 = Math.abs(arr[i] - arr[i - 1]);
            if (i == 1) {
                int abs = abs1;
                dp[i] = abs;
            } else {
                dp[i] = Math.min(abs1+dp[i-1], Math.abs(arr[i] - arr[i - 2])+dp[i-2]);
            }
        } int abs1 = Math.abs(arr[i] - arr[i - 1]); abs1 Math.abs(arr[i] - arr[i - 1]) Math.abs Math arr[i] - arr[i - 1] arr[i] arr i arr[i - 1] arr i - 1 i 1 if (i == 1) {
                int abs = abs1;
                dp[i] = abs;
            } else {
                dp[i] = Math.min(abs1+dp[i-1], Math.abs(arr[i] - arr[i - 2])+dp[i-2]);
            } i == 1 i 1 {
                int abs = abs1;
                dp[i] = abs;
            } int abs = abs1; abs abs1 dp[i] = abs dp[i] dp i abs {
                dp[i] = Math.min(abs1+dp[i-1], Math.abs(arr[i] - arr[i - 2])+dp[i-2]);
            } dp[i] = Math.min(abs1+dp[i-1], Math.abs(arr[i] - arr[i - 2])+dp[i-2]) dp[i] dp i Math.min(abs1+dp[i-1], Math.abs(arr[i] - arr[i - 2])+dp[i-2]) Math.min Math abs1+dp[i-1] abs1 dp[i-1] dp i-1 i 1 Math.abs(arr[i] - arr[i - 2])+dp[i-2] Math.abs(arr[i] - arr[i - 2]) Math.abs Math arr[i] - arr[i - 2] arr[i] arr i arr[i - 2] arr i - 2 i 2 dp[i-2] dp i-2 i 2 System.out.println(dp[x - 1]) System.out.println System.out System System.out dp[x - 1] dp x - 1 x 1 String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int arr[] = new int[x];
        for (int i = 0; i < x; i++)
            arr[i] = sc.nextInt();
        int dp[] = new int[x];
        if(x==1)
            System.out.println(arr[0]);
        for (int i = 1; i < x; i++) {
            int abs1 = Math.abs(arr[i] - arr[i - 1]);
            if (i == 1) {
                int abs = abs1;
                dp[i] = abs;
            } else {
                dp[i] = Math.min(abs1+dp[i-1], Math.abs(arr[i] - arr[i - 2])+dp[i-2]);
            }
        }
        System.out.println(dp[x - 1]);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int arr[] = new int[x];
        for (int i = 0; i < x; i++)
            arr[i] = sc.nextInt();
        int dp[] = new int[x];
        if(x==1)
            System.out.println(arr[0]);
        for (int i = 1; i < x; i++) {
            int abs1 = Math.abs(arr[i] - arr[i - 1]);
            if (i == 1) {
                int abs = abs1;
                dp[i] = abs;
            } else {
                dp[i] = Math.min(abs1+dp[i-1], Math.abs(arr[i] - arr[i - 2])+dp[i-2]);
            }
        }
        System.out.println(dp[x - 1]);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int arr[] = new int[x];
        for (int i = 0; i < x; i++)
            arr[i] = sc.nextInt();
        int dp[] = new int[x];
        if(x==1)
            System.out.println(arr[0]);
        for (int i = 1; i < x; i++) {
            int abs1 = Math.abs(arr[i] - arr[i - 1]);
            if (i == 1) {
                int abs = abs1;
                dp[i] = abs;
            } else {
                dp[i] = Math.min(abs1+dp[i-1], Math.abs(arr[i] - arr[i - 2])+dp[i-2]);
            }
        }
        System.out.println(dp[x - 1]);
    }
}
