import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		Reader.init(System.in);

		int n=Reader.nextInt();
		int[] h= new int[n+1];
		for(int i=1; i<=n; i++) {
			h[i]=Reader.nextInt();
		}
		
		int[] dp= new int[n+1];
		dp[1]=0;
		dp[2]= Math.abs(h[2]-h[1]);
		
		for(int i=3; i<=n; i++) {
			dp[i]= Math.min(dp[i-1]+ Math.abs(h[i]-h[i-1]),
					dp[i-2]+ Math.abs(h[i]-h[i-2]));
		}
		System.out.println(dp[n]);
}
}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {

        	tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
	
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
    

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util public class Main {
	public static void main(String[] args) throws IOException {
		Reader.init(System.in);

		int n=Reader.nextInt();
		int[] h= new int[n+1];
		for(int i=1; i<=n; i++) {
			h[i]=Reader.nextInt();
		}
		
		int[] dp= new int[n+1];
		dp[1]=0;
		dp[2]= Math.abs(h[2]-h[1]);
		
		for(int i=3; i<=n; i++) {
			dp[i]= Math.min(dp[i-1]+ Math.abs(h[i]-h[i-1]),
					dp[i-2]+ Math.abs(h[i]-h[i-2]));
		}
		System.out.println(dp[n]);
}
} Main public static void main(String[] args) throws IOException {
		Reader.init(System.in);

		int n=Reader.nextInt();
		int[] h= new int[n+1];
		for(int i=1; i<=n; i++) {
			h[i]=Reader.nextInt();
		}
		
		int[] dp= new int[n+1];
		dp[1]=0;
		dp[2]= Math.abs(h[2]-h[1]);
		
		for(int i=3; i<=n; i++) {
			dp[i]= Math.min(dp[i-1]+ Math.abs(h[i]-h[i-1]),
					dp[i-2]+ Math.abs(h[i]-h[i-2]));
		}
		System.out.println(dp[n]);
} main {
		Reader.init(System.in);

		int n=Reader.nextInt();
		int[] h= new int[n+1];
		for(int i=1; i<=n; i++) {
			h[i]=Reader.nextInt();
		}
		
		int[] dp= new int[n+1];
		dp[1]=0;
		dp[2]= Math.abs(h[2]-h[1]);
		
		for(int i=3; i<=n; i++) {
			dp[i]= Math.min(dp[i-1]+ Math.abs(h[i]-h[i-1]),
					dp[i-2]+ Math.abs(h[i]-h[i-2]));
		}
		System.out.println(dp[n]);
} Reader.init(System.in) Reader.init Reader System.in System System.in int n=Reader.nextInt(); n Reader.nextInt() Reader.nextInt Reader int[] h= new int[n+1]; h new int[n+1] n+1 n 1 for(int i=1; i<=n; i++) {
			h[i]=Reader.nextInt();
		} int i=1; int i=1; i 1 i<=n i n i++ i++ i {
			h[i]=Reader.nextInt();
		} {
			h[i]=Reader.nextInt();
		} h[i]=Reader.nextInt() h[i] h i Reader.nextInt() Reader.nextInt Reader int[] dp= new int[n+1]; dp new int[n+1] n+1 n 1 dp[1]=0 dp[1] dp 1 0 dp[2]= Math.abs(h[2]-h[1]) dp[2] dp 2 Math.abs(h[2]-h[1]) Math.abs Math h[2]-h[1] h[2] h 2 h[1] h 1 for(int i=3; i<=n; i++) {
			dp[i]= Math.min(dp[i-1]+ Math.abs(h[i]-h[i-1]),
					dp[i-2]+ Math.abs(h[i]-h[i-2]));
		} int i=3; int i=3; i 3 i<=n i n i++ i++ i {
			dp[i]= Math.min(dp[i-1]+ Math.abs(h[i]-h[i-1]),
					dp[i-2]+ Math.abs(h[i]-h[i-2]));
		} {
			dp[i]= Math.min(dp[i-1]+ Math.abs(h[i]-h[i-1]),
					dp[i-2]+ Math.abs(h[i]-h[i-2]));
		} dp[i]= Math.min(dp[i-1]+ Math.abs(h[i]-h[i-1]),
					dp[i-2]+ Math.abs(h[i]-h[i-2])) dp[i] dp i Math.min(dp[i-1]+ Math.abs(h[i]-h[i-1]),
					dp[i-2]+ Math.abs(h[i]-h[i-2])) Math.min Math dp[i-1]+ Math.abs(h[i]-h[i-1]) dp[i-1] dp 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 dp[i-2]+ Math.abs(h[i]-h[i-2]) dp[i-2] dp 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(dp[n]) System.out.println System.out System System.out dp[n] dp n String[] args args class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {

        	tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
	
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
    

} Reader static BufferedReader reader; reader static StringTokenizer tokenizer; tokenizer static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    } init {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    } reader = new BufferedReader(
                     new InputStreamReader(input) ) reader new BufferedReader(
                     new InputStreamReader(input) ) tokenizer = new StringTokenizer("") tokenizer new StringTokenizer("") InputStream input input static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {

        	tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    } next {
        while ( ! tokenizer.hasMoreTokens() ) {

        	tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    } while ( ! tokenizer.hasMoreTokens() ) {

        	tokenizer = new StringTokenizer(
                   reader.readLine() );
        } ! tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {

        	tokenizer = new StringTokenizer(
                   reader.readLine() );
        } tokenizer = new StringTokenizer(
                   reader.readLine() ) tokenizer new StringTokenizer(
                   reader.readLine() ) return tokenizer.nextToken(); tokenizer.nextToken() tokenizer.nextToken tokenizer static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    } nextInt {
        return Integer.parseInt( next() );
    } return Integer.parseInt( next() ); Integer.parseInt( next() ) Integer.parseInt Integer next() next static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    } nextDouble {
        return Double.parseDouble( next() );
    } return Double.parseDouble( next() ); Double.parseDouble( next() ) Double.parseDouble Double next() next static long nextLong() throws IOException {
        return Long.parseLong( next() );
    } nextLong {
        return Long.parseLong( next() );
    } return Long.parseLong( next() ); Long.parseLong( next() ) Long.parseLong Long next() next public class Main {
	public static void main(String[] args) throws IOException {
		Reader.init(System.in);

		int n=Reader.nextInt();
		int[] h= new int[n+1];
		for(int i=1; i<=n; i++) {
			h[i]=Reader.nextInt();
		}
		
		int[] dp= new int[n+1];
		dp[1]=0;
		dp[2]= Math.abs(h[2]-h[1]);
		
		for(int i=3; i<=n; i++) {
			dp[i]= Math.min(dp[i-1]+ Math.abs(h[i]-h[i-1]),
					dp[i-2]+ Math.abs(h[i]-h[i-2]));
		}
		System.out.println(dp[n]);
}
} public class Main {
	public static void main(String[] args) throws IOException {
		Reader.init(System.in);

		int n=Reader.nextInt();
		int[] h= new int[n+1];
		for(int i=1; i<=n; i++) {
			h[i]=Reader.nextInt();
		}
		
		int[] dp= new int[n+1];
		dp[1]=0;
		dp[2]= Math.abs(h[2]-h[1]);
		
		for(int i=3; i<=n; i++) {
			dp[i]= Math.min(dp[i-1]+ Math.abs(h[i]-h[i-1]),
					dp[i-2]+ Math.abs(h[i]-h[i-2]));
		}
		System.out.println(dp[n]);
}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		Reader.init(System.in);

		int n=Reader.nextInt();
		int[] h= new int[n+1];
		for(int i=1; i<=n; i++) {
			h[i]=Reader.nextInt();
		}
		
		int[] dp= new int[n+1];
		dp[1]=0;
		dp[2]= Math.abs(h[2]-h[1]);
		
		for(int i=3; i<=n; i++) {
			dp[i]= Math.min(dp[i-1]+ Math.abs(h[i]-h[i-1]),
					dp[i-2]+ Math.abs(h[i]-h[i-2]));
		}
		System.out.println(dp[n]);
}
}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {

        	tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
	
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
    

}