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

public class Main {
    public static void main (String[] args) {
        Scanner input = new Scanner(System.in);
        
        while (input.hasNext()) {
            int N = input.nextInt();
            int[] h = new int[N];
            
            for (int i = 0; i < h.length; ++i) {
                h[i] = input.nextInt();
            }
            
            int[] cost = new int[h.length];
            cost[0] = 0;
            cost[1] = Math.abs(h[1] - h[0]);
            
            for (int i = 2 ; i < h.length; ++i) {
                cost[i] = Math.min(cost[i - 1] + Math.abs(h[i] - h[i - 1]), cost[i - 2] + Math.abs(h[i] - h[i - 2]));
            }
            
            System.out.println(cost[cost.length - 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 input = new Scanner(System.in);
        
        while (input.hasNext()) {
            int N = input.nextInt();
            int[] h = new int[N];
            
            for (int i = 0; i < h.length; ++i) {
                h[i] = input.nextInt();
            }
            
            int[] cost = new int[h.length];
            cost[0] = 0;
            cost[1] = Math.abs(h[1] - h[0]);
            
            for (int i = 2 ; i < h.length; ++i) {
                cost[i] = Math.min(cost[i - 1] + Math.abs(h[i] - h[i - 1]), cost[i - 2] + Math.abs(h[i] - h[i - 2]));
            }
            
            System.out.println(cost[cost.length - 1]);
        }
    }
} Main public static void main (String[] args) {
        Scanner input = new Scanner(System.in);
        
        while (input.hasNext()) {
            int N = input.nextInt();
            int[] h = new int[N];
            
            for (int i = 0; i < h.length; ++i) {
                h[i] = input.nextInt();
            }
            
            int[] cost = new int[h.length];
            cost[0] = 0;
            cost[1] = Math.abs(h[1] - h[0]);
            
            for (int i = 2 ; i < h.length; ++i) {
                cost[i] = Math.min(cost[i - 1] + Math.abs(h[i] - h[i - 1]), cost[i - 2] + Math.abs(h[i] - h[i - 2]));
            }
            
            System.out.println(cost[cost.length - 1]);
        }
    } main {
        Scanner input = new Scanner(System.in);
        
        while (input.hasNext()) {
            int N = input.nextInt();
            int[] h = new int[N];
            
            for (int i = 0; i < h.length; ++i) {
                h[i] = input.nextInt();
            }
            
            int[] cost = new int[h.length];
            cost[0] = 0;
            cost[1] = Math.abs(h[1] - h[0]);
            
            for (int i = 2 ; i < h.length; ++i) {
                cost[i] = Math.min(cost[i - 1] + Math.abs(h[i] - h[i - 1]), cost[i - 2] + Math.abs(h[i] - h[i - 2]));
            }
            
            System.out.println(cost[cost.length - 1]);
        }
    } Scanner input = new Scanner(System.in); input new Scanner(System.in) while (input.hasNext()) {
            int N = input.nextInt();
            int[] h = new int[N];
            
            for (int i = 0; i < h.length; ++i) {
                h[i] = input.nextInt();
            }
            
            int[] cost = new int[h.length];
            cost[0] = 0;
            cost[1] = Math.abs(h[1] - h[0]);
            
            for (int i = 2 ; i < h.length; ++i) {
                cost[i] = Math.min(cost[i - 1] + Math.abs(h[i] - h[i - 1]), cost[i - 2] + Math.abs(h[i] - h[i - 2]));
            }
            
            System.out.println(cost[cost.length - 1]);
        } input.hasNext() input.hasNext input {
            int N = input.nextInt();
            int[] h = new int[N];
            
            for (int i = 0; i < h.length; ++i) {
                h[i] = input.nextInt();
            }
            
            int[] cost = new int[h.length];
            cost[0] = 0;
            cost[1] = Math.abs(h[1] - h[0]);
            
            for (int i = 2 ; i < h.length; ++i) {
                cost[i] = Math.min(cost[i - 1] + Math.abs(h[i] - h[i - 1]), cost[i - 2] + Math.abs(h[i] - h[i - 2]));
            }
            
            System.out.println(cost[cost.length - 1]);
        } int N = input.nextInt(); N input.nextInt() input.nextInt input int[] h = new int[N]; h new int[N] N for (int i = 0; i < h.length; ++i) {
                h[i] = input.nextInt();
            } int i = 0; int i = 0; i 0 i < h.length i h.length h h.length ++i ++i i {
                h[i] = input.nextInt();
            } {
                h[i] = input.nextInt();
            } h[i] = input.nextInt() h[i] h i input.nextInt() input.nextInt input int[] cost = new int[h.length]; cost new int[h.length] h.length h h.length cost[0] = 0 cost[0] cost 0 0 cost[1] = Math.abs(h[1] - h[0]) cost[1] cost 1 Math.abs(h[1] - h[0]) Math.abs Math h[1] - h[0] h[1] h 1 h[0] h 0 for (int i = 2 ; i < h.length; ++i) {
                cost[i] = Math.min(cost[i - 1] + Math.abs(h[i] - h[i - 1]), cost[i - 2] + Math.abs(h[i] - h[i - 2]));
            } int i = 2 ; int i = 2 ; i 2 i < h.length i h.length h h.length ++i ++i i {
                cost[i] = Math.min(cost[i - 1] + Math.abs(h[i] - h[i - 1]), cost[i - 2] + Math.abs(h[i] - h[i - 2]));
            } {
                cost[i] = Math.min(cost[i - 1] + Math.abs(h[i] - h[i - 1]), cost[i - 2] + Math.abs(h[i] - h[i - 2]));
            } cost[i] = Math.min(cost[i - 1] + Math.abs(h[i] - h[i - 1]), cost[i - 2] + Math.abs(h[i] - h[i - 2])) cost[i] cost i Math.min(cost[i - 1] + Math.abs(h[i] - h[i - 1]), cost[i - 2] + Math.abs(h[i] - h[i - 2])) Math.min Math cost[i - 1] + Math.abs(h[i] - h[i - 1]) cost[i - 1] cost i - 1 i 1 Math.abs(h[i] - h[i - 1]) Math.abs Math h[i] - h[i - 1] h[i] h i h[i - 1] h i - 1 i 1 cost[i - 2] + Math.abs(h[i] - h[i - 2]) cost[i - 2] cost i - 2 i 2 Math.abs(h[i] - h[i - 2]) Math.abs Math h[i] - h[i - 2] h[i] h i h[i - 2] h i - 2 i 2 System.out.println(cost[cost.length - 1]) System.out.println System.out System System.out cost[cost.length - 1] cost cost.length - 1 cost.length cost cost.length 1 String[] args args public class Main {
    public static void main (String[] args) {
        Scanner input = new Scanner(System.in);
        
        while (input.hasNext()) {
            int N = input.nextInt();
            int[] h = new int[N];
            
            for (int i = 0; i < h.length; ++i) {
                h[i] = input.nextInt();
            }
            
            int[] cost = new int[h.length];
            cost[0] = 0;
            cost[1] = Math.abs(h[1] - h[0]);
            
            for (int i = 2 ; i < h.length; ++i) {
                cost[i] = Math.min(cost[i - 1] + Math.abs(h[i] - h[i - 1]), cost[i - 2] + Math.abs(h[i] - h[i - 2]));
            }
            
            System.out.println(cost[cost.length - 1]);
        }
    }
} public class Main {
    public static void main (String[] args) {
        Scanner input = new Scanner(System.in);
        
        while (input.hasNext()) {
            int N = input.nextInt();
            int[] h = new int[N];
            
            for (int i = 0; i < h.length; ++i) {
                h[i] = input.nextInt();
            }
            
            int[] cost = new int[h.length];
            cost[0] = 0;
            cost[1] = Math.abs(h[1] - h[0]);
            
            for (int i = 2 ; i < h.length; ++i) {
                cost[i] = Math.min(cost[i - 1] + Math.abs(h[i] - h[i - 1]), cost[i - 2] + Math.abs(h[i] - h[i - 2]));
            }
            
            System.out.println(cost[cost.length - 1]);
        }
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        Scanner input = new Scanner(System.in);
        
        while (input.hasNext()) {
            int N = input.nextInt();
            int[] h = new int[N];
            
            for (int i = 0; i < h.length; ++i) {
                h[i] = input.nextInt();
            }
            
            int[] cost = new int[h.length];
            cost[0] = 0;
            cost[1] = Math.abs(h[1] - h[0]);
            
            for (int i = 2 ; i < h.length; ++i) {
                cost[i] = Math.min(cost[i - 1] + Math.abs(h[i] - h[i - 1]), cost[i - 2] + Math.abs(h[i] - h[i - 2]));
            }
            
            System.out.println(cost[cost.length - 1]);
        }
    }
}
