import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int a[]=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    int[] dp=new int[n];
    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.print(dp[n-1]);
  }
} import java.util.*; util.* java class Main {
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int a[]=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    int[] dp=new int[n];
    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.print(dp[n-1]);
  }
} Main public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int a[]=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    int[] dp=new int[n];
    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.print(dp[n-1]);
  } main {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int a[]=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    int[] dp=new int[n];
    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.print(dp[n-1]);
  } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int a[]=new int[n]; a new int[n] n for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      a[i]=sc.nextInt();
    } {
      a[i]=sc.nextInt();
    } a[i]=sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc int[] dp=new int[n]; dp new int[n] n 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.print(dp[n-1]) System.out.print System.out System System.out dp[n-1] dp n-1 n 1 String[] args args
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int a[]=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    int[] dp=new int[n];
    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.print(dp[n-1]);
  }
}