import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] h = new int[N];
        long[] min = new long[N];
        
        h[0] = Integer.parseInt(sc.next());
        h[1] = Integer.parseInt(sc.next());
        min[0] = 0;
        min[1] = zetta(h[0], h[1]);
        
        if(N > 2) {
            for(int i = 2; i < N; i++) {
                h[i] = Integer.parseInt(sc.next());
                if(zetta(h[i], h[i-1])+ min[i-1] > zetta(h[i], h[i-2]) + min[i-2]) {
                    min[i] = zetta(h[i], h[i-2]) + min[i-2];
                }else {
                    min[i] = zetta(h[i], h[i-1]) + min[i-1];
                }
            }
        }
        System.out.println(min[N-1]);
    }
    
    public static int zetta(int a, int b) {
        if(a >= b) {
            return a - b;
        }else {
            return b - a;
        }
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] h = new int[N];
        long[] min = new long[N];
        
        h[0] = Integer.parseInt(sc.next());
        h[1] = Integer.parseInt(sc.next());
        min[0] = 0;
        min[1] = zetta(h[0], h[1]);
        
        if(N > 2) {
            for(int i = 2; i < N; i++) {
                h[i] = Integer.parseInt(sc.next());
                if(zetta(h[i], h[i-1])+ min[i-1] > zetta(h[i], h[i-2]) + min[i-2]) {
                    min[i] = zetta(h[i], h[i-2]) + min[i-2];
                }else {
                    min[i] = zetta(h[i], h[i-1]) + min[i-1];
                }
            }
        }
        System.out.println(min[N-1]);
    }
    
    public static int zetta(int a, int b) {
        if(a >= b) {
            return a - b;
        }else {
            return b - a;
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] h = new int[N];
        long[] min = new long[N];
        
        h[0] = Integer.parseInt(sc.next());
        h[1] = Integer.parseInt(sc.next());
        min[0] = 0;
        min[1] = zetta(h[0], h[1]);
        
        if(N > 2) {
            for(int i = 2; i < N; i++) {
                h[i] = Integer.parseInt(sc.next());
                if(zetta(h[i], h[i-1])+ min[i-1] > zetta(h[i], h[i-2]) + min[i-2]) {
                    min[i] = zetta(h[i], h[i-2]) + min[i-2];
                }else {
                    min[i] = zetta(h[i], h[i-1]) + min[i-1];
                }
            }
        }
        System.out.println(min[N-1]);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] h = new int[N];
        long[] min = new long[N];
        
        h[0] = Integer.parseInt(sc.next());
        h[1] = Integer.parseInt(sc.next());
        min[0] = 0;
        min[1] = zetta(h[0], h[1]);
        
        if(N > 2) {
            for(int i = 2; i < N; i++) {
                h[i] = Integer.parseInt(sc.next());
                if(zetta(h[i], h[i-1])+ min[i-1] > zetta(h[i], h[i-2]) + min[i-2]) {
                    min[i] = zetta(h[i], h[i-2]) + min[i-2];
                }else {
                    min[i] = zetta(h[i], h[i-1]) + min[i-1];
                }
            }
        }
        System.out.println(min[N-1]);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] h = new int[N]; h new int[N] N long[] min = new long[N]; min new long[N] N h[0] = Integer.parseInt(sc.next()) h[0] h 0 Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc h[1] = Integer.parseInt(sc.next()) h[1] h 1 Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc min[0] = 0 min[0] min 0 0 min[1] = zetta(h[0], h[1]) min[1] min 1 zetta(h[0], h[1]) zetta h[0] h 0 h[1] h 1 if(N > 2) {
            for(int i = 2; i < N; i++) {
                h[i] = Integer.parseInt(sc.next());
                if(zetta(h[i], h[i-1])+ min[i-1] > zetta(h[i], h[i-2]) + min[i-2]) {
                    min[i] = zetta(h[i], h[i-2]) + min[i-2];
                }else {
                    min[i] = zetta(h[i], h[i-1]) + min[i-1];
                }
            }
        } N > 2 N 2 {
            for(int i = 2; i < N; i++) {
                h[i] = Integer.parseInt(sc.next());
                if(zetta(h[i], h[i-1])+ min[i-1] > zetta(h[i], h[i-2]) + min[i-2]) {
                    min[i] = zetta(h[i], h[i-2]) + min[i-2];
                }else {
                    min[i] = zetta(h[i], h[i-1]) + min[i-1];
                }
            }
        } for(int i = 2; i < N; i++) {
                h[i] = Integer.parseInt(sc.next());
                if(zetta(h[i], h[i-1])+ min[i-1] > zetta(h[i], h[i-2]) + min[i-2]) {
                    min[i] = zetta(h[i], h[i-2]) + min[i-2];
                }else {
                    min[i] = zetta(h[i], h[i-1]) + min[i-1];
                }
            } int i = 2; int i = 2; i 2 i < N i N i++ i++ i {
                h[i] = Integer.parseInt(sc.next());
                if(zetta(h[i], h[i-1])+ min[i-1] > zetta(h[i], h[i-2]) + min[i-2]) {
                    min[i] = zetta(h[i], h[i-2]) + min[i-2];
                }else {
                    min[i] = zetta(h[i], h[i-1]) + min[i-1];
                }
            } {
                h[i] = Integer.parseInt(sc.next());
                if(zetta(h[i], h[i-1])+ min[i-1] > zetta(h[i], h[i-2]) + min[i-2]) {
                    min[i] = zetta(h[i], h[i-2]) + min[i-2];
                }else {
                    min[i] = zetta(h[i], h[i-1]) + min[i-1];
                }
            } h[i] = Integer.parseInt(sc.next()) h[i] h i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc if(zetta(h[i], h[i-1])+ min[i-1] > zetta(h[i], h[i-2]) + min[i-2]) {
                    min[i] = zetta(h[i], h[i-2]) + min[i-2];
                }else {
                    min[i] = zetta(h[i], h[i-1]) + min[i-1];
                } zetta(h[i], h[i-1])+ min[i-1] > zetta(h[i], h[i-2]) + min[i-2] zetta(h[i], h[i-1])+ min[i-1] zetta(h[i], h[i-1]) zetta h[i] h i h[i-1] h i-1 i 1 min[i-1] min i-1 i 1 zetta(h[i], h[i-2]) + min[i-2] zetta(h[i], h[i-2]) zetta h[i] h i h[i-2] h i-2 i 2 min[i-2] min i-2 i 2 {
                    min[i] = zetta(h[i], h[i-2]) + min[i-2];
                } min[i] = zetta(h[i], h[i-2]) + min[i-2] min[i] min i zetta(h[i], h[i-2]) + min[i-2] zetta(h[i], h[i-2]) zetta h[i] h i h[i-2] h i-2 i 2 min[i-2] min i-2 i 2 {
                    min[i] = zetta(h[i], h[i-1]) + min[i-1];
                } min[i] = zetta(h[i], h[i-1]) + min[i-1] min[i] min i zetta(h[i], h[i-1]) + min[i-1] zetta(h[i], h[i-1]) zetta h[i] h i h[i-1] h i-1 i 1 min[i-1] min i-1 i 1 System.out.println(min[N-1]) System.out.println System.out System System.out min[N-1] min N-1 N 1 String[] args args public static int zetta(int a, int b) {
        if(a >= b) {
            return a - b;
        }else {
            return b - a;
        }
    } zetta {
        if(a >= b) {
            return a - b;
        }else {
            return b - a;
        }
    } if(a >= b) {
            return a - b;
        }else {
            return b - a;
        } a >= b a b {
            return a - b;
        } return a - b; a - b a b {
            return b - a;
        } return b - a; b - a b a int a a int b b public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] h = new int[N];
        long[] min = new long[N];
        
        h[0] = Integer.parseInt(sc.next());
        h[1] = Integer.parseInt(sc.next());
        min[0] = 0;
        min[1] = zetta(h[0], h[1]);
        
        if(N > 2) {
            for(int i = 2; i < N; i++) {
                h[i] = Integer.parseInt(sc.next());
                if(zetta(h[i], h[i-1])+ min[i-1] > zetta(h[i], h[i-2]) + min[i-2]) {
                    min[i] = zetta(h[i], h[i-2]) + min[i-2];
                }else {
                    min[i] = zetta(h[i], h[i-1]) + min[i-1];
                }
            }
        }
        System.out.println(min[N-1]);
    }
    
    public static int zetta(int a, int b) {
        if(a >= b) {
            return a - b;
        }else {
            return b - a;
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] h = new int[N];
        long[] min = new long[N];
        
        h[0] = Integer.parseInt(sc.next());
        h[1] = Integer.parseInt(sc.next());
        min[0] = 0;
        min[1] = zetta(h[0], h[1]);
        
        if(N > 2) {
            for(int i = 2; i < N; i++) {
                h[i] = Integer.parseInt(sc.next());
                if(zetta(h[i], h[i-1])+ min[i-1] > zetta(h[i], h[i-2]) + min[i-2]) {
                    min[i] = zetta(h[i], h[i-2]) + min[i-2];
                }else {
                    min[i] = zetta(h[i], h[i-1]) + min[i-1];
                }
            }
        }
        System.out.println(min[N-1]);
    }
    
    public static int zetta(int a, int b) {
        if(a >= b) {
            return a - b;
        }else {
            return b - a;
        }
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] h = new int[N];
        long[] min = new long[N];
        
        h[0] = Integer.parseInt(sc.next());
        h[1] = Integer.parseInt(sc.next());
        min[0] = 0;
        min[1] = zetta(h[0], h[1]);
        
        if(N > 2) {
            for(int i = 2; i < N; i++) {
                h[i] = Integer.parseInt(sc.next());
                if(zetta(h[i], h[i-1])+ min[i-1] > zetta(h[i], h[i-2]) + min[i-2]) {
                    min[i] = zetta(h[i], h[i-2]) + min[i-2];
                }else {
                    min[i] = zetta(h[i], h[i-1]) + min[i-1];
                }
            }
        }
        System.out.println(min[N-1]);
    }
    
    public static int zetta(int a, int b) {
        if(a >= b) {
            return a - b;
        }else {
            return b - a;
        }
    }
}