import java.util.*;

public class Main{
  public static int dp[]=new int[100001];
  public static int go(int a[],int i){
    if(i==a.length-1)
    {
      return 0;
    }
    if(i>a.length-1)
    {
      return 100000;
    }
    if(dp[i]!=-1)
    return dp[i];
    int one=10000,two=10000;
    if(i+1<=a.length-1)
    one=Math.abs(a[i]-a[i+1])+go(a,i+1);
    if(i+2<=a.length-1)
    two=Math.abs(a[i]-a[i+2])+go(a,i+2);
    dp[i]=Math.min(one,two);
    return dp[i];
  }
  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++){
    dp[i]=-1;
    a[i]=sc.nextInt();
    }
    dp[n]=-1;
    System.out.print(go(a,0));
  }
} import java.util.*; util.* java public class Main{
  public static int dp[]=new int[100001];
  public static int go(int a[],int i){
    if(i==a.length-1)
    {
      return 0;
    }
    if(i>a.length-1)
    {
      return 100000;
    }
    if(dp[i]!=-1)
    return dp[i];
    int one=10000,two=10000;
    if(i+1<=a.length-1)
    one=Math.abs(a[i]-a[i+1])+go(a,i+1);
    if(i+2<=a.length-1)
    two=Math.abs(a[i]-a[i+2])+go(a,i+2);
    dp[i]=Math.min(one,two);
    return dp[i];
  }
  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++){
    dp[i]=-1;
    a[i]=sc.nextInt();
    }
    dp[n]=-1;
    System.out.print(go(a,0));
  }
} Main public static int dp[]=new int[100001]; dp new int[100001] 100001 public static int go(int a[],int i){
    if(i==a.length-1)
    {
      return 0;
    }
    if(i>a.length-1)
    {
      return 100000;
    }
    if(dp[i]!=-1)
    return dp[i];
    int one=10000,two=10000;
    if(i+1<=a.length-1)
    one=Math.abs(a[i]-a[i+1])+go(a,i+1);
    if(i+2<=a.length-1)
    two=Math.abs(a[i]-a[i+2])+go(a,i+2);
    dp[i]=Math.min(one,two);
    return dp[i];
  } go {
    if(i==a.length-1)
    {
      return 0;
    }
    if(i>a.length-1)
    {
      return 100000;
    }
    if(dp[i]!=-1)
    return dp[i];
    int one=10000,two=10000;
    if(i+1<=a.length-1)
    one=Math.abs(a[i]-a[i+1])+go(a,i+1);
    if(i+2<=a.length-1)
    two=Math.abs(a[i]-a[i+2])+go(a,i+2);
    dp[i]=Math.min(one,two);
    return dp[i];
  } if(i==a.length-1)
    {
      return 0;
    } i==a.length-1 i a.length-1 a.length a a.length 1 {
      return 0;
    } return 0; 0 if(i>a.length-1)
    {
      return 100000;
    } i>a.length-1 i a.length-1 a.length a a.length 1 {
      return 100000;
    } return 100000; 100000 if(dp[i]!=-1)
    return dp[i]; dp[i]!=-1 dp[i] dp i -1 1 return dp[i]; dp[i] dp i int one=10000 one 10000 two=10000; two 10000 if(i+1<=a.length-1)
    one=Math.abs(a[i]-a[i+1])+go(a,i+1); i+1<=a.length-1 i+1 i 1 a.length-1 a.length a a.length 1 one=Math.abs(a[i]-a[i+1])+go(a,i+1) one Math.abs(a[i]-a[i+1])+go(a,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 go(a,i+1) go a i+1 i 1 if(i+2<=a.length-1)
    two=Math.abs(a[i]-a[i+2])+go(a,i+2); i+2<=a.length-1 i+2 i 2 a.length-1 a.length a a.length 1 two=Math.abs(a[i]-a[i+2])+go(a,i+2) two Math.abs(a[i]-a[i+2])+go(a,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 go(a,i+2) go a i+2 i 2 dp[i]=Math.min(one,two) dp[i] dp i Math.min(one,two) Math.min Math one two return dp[i]; dp[i] dp i int a[] a int i i 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++){
    dp[i]=-1;
    a[i]=sc.nextInt();
    }
    dp[n]=-1;
    System.out.print(go(a,0));
  } main {
    Scanner sc=new Scanner(System.in); 
    int n=sc.nextInt();
    int a[]=new int[n];
    for(int i=0;i<n;i++){
    dp[i]=-1;
    a[i]=sc.nextInt();
    }
    dp[n]=-1;
    System.out.print(go(a,0));
  } 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++){
    dp[i]=-1;
    a[i]=sc.nextInt();
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
    dp[i]=-1;
    a[i]=sc.nextInt();
    } {
    dp[i]=-1;
    a[i]=sc.nextInt();
    } dp[i]=-1 dp[i] dp i -1 1 a[i]=sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc dp[n]=-1 dp[n] dp n -1 1 System.out.print(go(a,0)) System.out.print System.out System System.out go(a,0) go a 0 String[] args args public class Main{
  public static int dp[]=new int[100001];
  public static int go(int a[],int i){
    if(i==a.length-1)
    {
      return 0;
    }
    if(i>a.length-1)
    {
      return 100000;
    }
    if(dp[i]!=-1)
    return dp[i];
    int one=10000,two=10000;
    if(i+1<=a.length-1)
    one=Math.abs(a[i]-a[i+1])+go(a,i+1);
    if(i+2<=a.length-1)
    two=Math.abs(a[i]-a[i+2])+go(a,i+2);
    dp[i]=Math.min(one,two);
    return dp[i];
  }
  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++){
    dp[i]=-1;
    a[i]=sc.nextInt();
    }
    dp[n]=-1;
    System.out.print(go(a,0));
  }
} public class Main{
  public static int dp[]=new int[100001];
  public static int go(int a[],int i){
    if(i==a.length-1)
    {
      return 0;
    }
    if(i>a.length-1)
    {
      return 100000;
    }
    if(dp[i]!=-1)
    return dp[i];
    int one=10000,two=10000;
    if(i+1<=a.length-1)
    one=Math.abs(a[i]-a[i+1])+go(a,i+1);
    if(i+2<=a.length-1)
    two=Math.abs(a[i]-a[i+2])+go(a,i+2);
    dp[i]=Math.min(one,two);
    return dp[i];
  }
  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++){
    dp[i]=-1;
    a[i]=sc.nextInt();
    }
    dp[n]=-1;
    System.out.print(go(a,0));
  }
} Main
import java.util.*;

public class Main{
  public static int dp[]=new int[100001];
  public static int go(int a[],int i){
    if(i==a.length-1)
    {
      return 0;
    }
    if(i>a.length-1)
    {
      return 100000;
    }
    if(dp[i]!=-1)
    return dp[i];
    int one=10000,two=10000;
    if(i+1<=a.length-1)
    one=Math.abs(a[i]-a[i+1])+go(a,i+1);
    if(i+2<=a.length-1)
    two=Math.abs(a[i]-a[i+2])+go(a,i+2);
    dp[i]=Math.min(one,two);
    return dp[i];
  }
  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++){
    dp[i]=-1;
    a[i]=sc.nextInt();
    }
    dp[n]=-1;
    System.out.print(go(a,0));
  }
}