jiahuimbzuai/CoQuIR huggingface dataset:
//  [c]
#include<stdio.h>
int main()
{
    int i,l;
    char s[100];
    scanf("%s",s);
    l=strlen(s); 
    printf("%c%d%c",s[0],l-2,s[l-1]);
        
  return 0;  
}
//  [c]
/* ex6_2
   tamayama */

#include<stdio.h>
#define SIZE 101

int main(void){
    char str1[SIZE];    /*文字列の配列を用意*/
    int i;
    int count=0;
    char first;
    char final;

    for(i=0;i<SIZE;i++){    /*ヌル文字を挿入*/
        str1[i] = '\0';
    }

    scanf("%s",str1);    /*入力された文字数をカウントする*/
    for(i=0;i<SIZE;i++){
        if(str1[i] != '\0'){
            count++;
        }
    }
    first = str1[0];    /*最初の文字*/
    final = str1[count-1];    /*最後の文字*/
    printf("%c%d%c\n",first,count-2,final);    /*真ん中の文字数は、（全体の文字数）-2*/
    return 0;
}
//  [c]
#include<stdio.h>
int main(void){
  int i;
  char s[101];
  int ct=0;
  
  for(i=0;i<101;i++){
    s[i]=0;
  }
  
  for(i=0;i<101;i++){
    scanf("%c",&s[i]);
  }
  
  for(i=0;i<101;i++){
    if(s[i] != 0)ct++;
    else break;
  }
  
  printf("%c%d%c",s[0],ct-2,s[ct-1]);
  
  return 0;
}
//  [c]
#include<stdio.h>
int main(void){
  int i;
  char s[101];
  int ct=0;
  
  for(i=0;i<100;i++){
    s[i]=0;
  }
  
  for(i=0;i<100;i++){
    scanf("%c",&s[i]);
  }
  
  for(i=0;i<=100;i++){
    if(s[i] != 0)ct++;
    else break;
  }
  
  printf("%c%d%c",s[0],ct-2,s[ct-1]);
  
  return 0;
}
//  [javascript]
'use strict'
 
function main(s) {
  let n = s.split("\n")[0].split('');
  let init = n.slice(0)[0];
  let end = n.slice(-1)[0];
  let num = n.length - 2;
  console.log(`${init}${num}${end}`);
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(inp) {
    var input = inp.split("\n");
    var s = input[0];
    var num = s.length - 2;
    var result = s[0] + num + s[s.length - 1];
    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict'

function main(input) {
  input = `${input.slice(0, 1)}${input.length - 2}${input.slice(-1)}`
  console.log(input)
}
main(
  require('fs')
    .readFileSync('/dev/stdin', 'utf8')
    .trim()
)
//  [javascript]
function main(input) {
  const s = input.split('');
  
  const a = s[0].toString();
  const b = (s.length - 2).toString();
  const c = s[s.length - 1];
  
  let result = a + b + c;
  
  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'));
//  [javascript]
function main(input) {
  const s = input.split('');
  
  const a = s[0];
  const b = s.length - 2;
  const c = s[s.length - 1];
  
  const result = a.toString()+b.toString()+c.toString();
  
  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'));
//  [javascript]
function main(input) {
  const s = input.split('');
  
  const a = s[0];
  const b = s.length - 2;
  const c = s[s.length - 1];
  
  const result = a+b+c;
  
  console.log(result.trim(' '));
  
  
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'));
//  [go]
package main

import (
  "fmt"
  "strconv"
)

func main() {
  var S, str_count string
  fmt.Scan(&S)

  s_first := S[0:1]
  s_count := len(S) - 2
  s_last := S[s_count + 1:s_count + 2]
  str_count = strconv.Itoa(s_count)
  s := s_first + str_count + s_last
  fmt.Println(s)
}
//  [go]
package main

import "fmt"

func main() {
	var s string
	fmt.Scanf("%s", &s)
	l := len(s)
	fmt.Printf("%s%d%s\n", string(s[0]), l-2, string(s[l-1]))
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	s := nextLine()
	first := s[0:1]
	last := s[len(s)-1:]
	num := strconv.Itoa(len(s) - 2)

	fmt.Println(num)

	slice := []string{first, num, last}

	fmt.Println(strings.Join(slice, ""))
}
//  [go]
package main 

import {
  "fmt"
  "strings"
}

func main() {
  var s string;
  fmt.Scan(&s);
  
  sLen := len(s);
  fmt.printf("%s%d%s", s[0:1], sLen, s[sLen-1:sLen]);
}
//  [ruby]
s = gets.chomp

aida = (s.size) - 2
aida = aida.to_s
puts s[0] + aida + s[s.size-1]
//  [ruby]
s = gets.chomp
puts "#{s[0]}#{s[1..-2].length}#{s[-1]}"
//  [ruby]
s = gets.chomp
puts s[0] + (s.length - 2).to_s + s[s.length - 1]
//  [ruby]
s=gets.chomp
puts s[0]+s.size.to_s-2+s[-1]
//  [ruby]
s=gets.chomp
puts s[0]+s.size-2+s[-1]
//  [ruby]
s = gets.chomp
puts s[0] + (s.length - 2).to_s + s[s.length -1]
//  [rust]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let s = get!(String).chars().collect::<Vec<_>>();
    println!("{}{}{}", s.first().unwrap().to_string(), (s.len() - 2).to_string(), s.last().unwrap().to_string());
}
//  [rust]
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s = buf.trim().chars().collect::<Vec<char>>();
	let t = format!("{}{}{}", s[0], s.len() - 2, s[s.len() - 1]);
	println!("{}", t);
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars,
    };
    println!("{}{}{}",s[0],s.len()-2,s[s.len()-1]);
}
//  [rust]
fn main() {
    proconio::input! {
    a:String,
    }
    let a=a.chars().collect_vec();
    println!("{}{}{}",a[0],a.len()-2,a[a.len()-1])
}
//  [rust]
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s : String = get_one();
    let n = s.len();
    let s_ind = s.chars().collect::<Vec<char>>();
    println!("{}{}{}", s_ind[0], n-2, s_ind[n-1]);
}
//  [rust]
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let s: String = read();
    let price = 700 + 100 * s.chars().filter(|&s| s == 'o').count();
    println!("{}", price);
}
//  [swift]
extension String: CollectionType {
    func at(idx: Int) -> Character {
        return self[self.startIndex.advancedBy(idx)]
    }
}
let s = readLine()!
let n = s.count
print("\(s.at(0))\(n-2)\(s.at(n-1))")
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let s = readLine()!.toArray()
print(s[0]+"\(s.count-2)"+s[s.count-1])
//  [swift]
let s=readLine()!.characters.map{$0}
print("\(s[0])\(s.count-2)\(s.last!)")
//  [swift]
let s=readLine()!.characters.map{$0}
print(s[0]+"\(s.count-2)"+s[s.count-1])
//  [swift]
let s=readLine()!.characters
print(s[0]+"\(s.count-2)"+s[s.count-1])
//  [typescript]
import * as fs from 'fs';

const s: string = fs.readFileSync('/dev/stdin', 'utf8').trim();
console.log(s.substring(0, 1) + (s.length - 2).toString() + s.substring(s.length-1));
//  [typescript]
const log = console.log;

// ----

function Main(input: string): void {
  const str = input.trim();
  const len = str.length;
  log(`${str[0]}${len - 2}${str[len - 1]}`);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const gojo=(a:number,b:number):number=>{if(a%b===0)return b;return gojo(b,a%b)};
const main=()=>{
  let s=ts()
  to(s[0]+(s.length-2)+s[s.length-1])
}
main()
//  [typescript]
function main(input: string) {
    input = input.split("\n")[0];
    console.log(input.slice(0, 1) + input.length - 2 + input.slice(-1));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	// input = input.split(" ");
	// 文字列から10進数に変換するときはparseIntを使います
	const len = input.length;
	console.log(`${input[0]}${(len-2)}${input[len-1]}`);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	// input = input.split(" ");
	// 文字列から10進数に変換するときはparseIntを使います
	const len = input.length;
	console.log(input[0] + (len-2) + input[len-1]);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [python]
def main():
  n = int(input())
  hs = tuple(map(int, input().split()))

  a, b = 0, abs(hs[1] - hs[0])

  for i in range(2, n):
    c = hs[i]
    d1 = a + abs(c - hs[i-2])
    d2 = b + abs(c - hs[i-1])
    a, b = b, d1 if d1 <= d2 else d2

  print(b)

if __name__ == "__main__":
  main()
//  [python]
def main():
  n = int(input())
  hs = tuple(map(int, input().split()))

  a, b = 0, abs(hs[1] - hs[0])

  for i in range(2, n):
    d1 = a + abs(hs[i] - hs[i-2])
    d2 = b + abs(hs[i] - hs[i-1])
    a, b = b, d1 if d1 <= d2 else d2

  print(b)

if __name__ == "__main__":
  main()
//  [python]
# dpA - Frog 1
"""
Example:
x y
  x y
    x y ...
        x y (y: answer)
"""
def main():
    n = int(input())
    A = tuple(map(int, input().split()))
    x, y = 0, abs(A[1] - A[0])
    for i in range(2, n):
        dif1 = x + abs(A[i] - A[i - 2])
        dif2 = y + abs(A[i] - A[i - 1])
        x = y
        y = dif1 if dif1 <= dif2 else dif2
    print(y)


if __name__ == "__main__":
    main()
//  [python]
#include<bits/stdc++.h>
using namespace std;
int solve(vector<int>&a,int n){
    if(n==2)return abs(a[1]-a[0]);
    if(n<2) return 0;
    return min(abs(a[n-2]-a[n-1])+solve(a,n-1),abs(a[n-3]-a[n-1])+solve(a,n-2));
}
int main(){
    int n;
    cin>>n;
    vector<int>a;
    for(int i=0;i<n;i++){
        int s;cin>>s;a.push_back(s);
    }
    cout<<solve(a,n);
}
//  [python]

n = int(input())
li = list(map(int,input().split()))

dp = [[-1 for i in range(1100)] for j in range(1100)]
ans = [100000]*n
ans[0] = 0
def solve(a,b,dp,li):
    # print(f"{a,b}")
    if dp[a][b] !=-1 :
        # print(f"結果{dp[a][b]}")
        return dp[a][b]
    else:
        dp[a][b] = abs(li[a]-li[b])
        # print(f"結果{a,b,dp[a][b]}")
        return dp[a][b]

for i in range(2,n+1):
    # print(i)
    if i == 2:
        dp[1][0] = abs(li[1]-li[0])
        ans[i-1] = dp[1][0]
    else:
        # print(solve(i-1,i-2,dp,li)+ans[i-2],solve(i-1,i-3,dp,li)+ans[i-3])
        # print(solve(i-1,i-2,dp,li),solve(i-1,i-3,dp,li))
        # print(ans[i-2],ans[i-3])
        # print(li[i-1],li[i-3])
        ans[i-1] = min(solve(i-1,i-2,dp,li)+ans[i-2],solve(i-1,i-3,dp,li)+ans[i-3])

print(ans[-1])
# print(dp)
//  [python]

n = int(input())
li = list(map(int,input().split()))

dp = [[-1 for i in range(10000)] for j in range(10000)]
ans = [100000]*n
ans[0] = 0
def solve(a,b,dp,li):
    # print(f"{a,b}")
    if dp[a][b] !=-1 :
        # print(f"結果{dp[a][b]}")
        return dp[a][b]
    else:
        dp[a][b] = abs(li[a]-li[b])
        # print(f"結果{a,b,dp[a][b]}")
        return dp[a][b]

for i in range(2,n+1):
    # print(i)
    if i == 2:
        dp[1][0] = abs(li[1]-li[0])
        ans[i-1] = dp[1][0]
    else:
        # print(solve(i-1,i-2,dp,li)+ans[i-2],solve(i-1,i-3,dp,li)+ans[i-3])
        # print(solve(i-1,i-2,dp,li),solve(i-1,i-3,dp,li))
        # print(ans[i-2],ans[i-3])
        # print(li[i-1],li[i-3])
        ans[i-1] = min(solve(i-1,i-2,dp,li)+ans[i-2],solve(i-1,i-3,dp,li)+ans[i-3])

print(ans[-1])
# print(dp)
//  [java]
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static long mod = 1000000007;

	public static void main(String[] args) {
		// AtCoder_A
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int H[] = new int[N+1];
		Arrays.fill(H, 0);
		for(int i=0; i<N; i++) {
			H[i] = sc.nextInt();
		}
	    // Scannerクラスのインスタンスをクローズ
		sc.close();

		long ans = 0;
		int now = 0;
		while(now < N-1) {
			if(Math.abs(H[now]-H[now+2]) < Math.abs(H[now]-H[now+1])+Math.abs(H[now+1]-H[now+2])) {
				ans += Math.abs(H[now]-H[now+2]);
				now += 2;
			} else {
				ans += Math.abs(H[now]-H[now+1]);
				now += 1;
			}
		}

		// 出力
		System.out.println(ans);
	}
}
//  [java]
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){


			int N = scan.nextInt();
			int K = scan.nextInt();
			long[]h = new long[N];
			for(int i = 0;i<N;i++)h[i] =scan.nextLong();

			long[]dp = new long[N+1];

			for(int i = 1;i<N;i++) {
				if(i-K>=0){
					long dpcost = Long.MAX_VALUE;
					int dpnum = 0;
					for(int j = 1;j<=K;j++) {
						if(dpcost>dp[i-j]+Math.abs(h[i]-h[i-j])) {
							dpcost = dp[i-j]+Math.abs(h[i]-h[i-j]);
							dpnum = j;
						}
					}

					dp[i] =dpcost;

				}else {
					long dpcost = Long.MAX_VALUE;
					int dpnum = 0;
					for(int j = 1;j<=i;j++) {
						if(dpcost>dp[i-j]+Math.abs(h[i]-h[i-j])) {
							dpcost = dp[i-j]+Math.abs(h[i]-h[i-j]);
							dpnum = j;
						}

					}


					dp[i] =dpcost;

				}
			}

			System.out.println(dp[N-1]);





		}


	}


}
//  [java]
import java.util.Scanner;

public class Main{
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){


			int N = scan.nextInt();
			int[]h = new int[N];
			for(int i = 0;i<N;i++)h[i] =scan.nextInt();

			long[]dp = new long[N+2];

			for(int i = 1;i<N;i++) {
				if(i==1) {
					int a =  Math.abs(h[i]-h[i-1]);
					dp[i] = dp[i-1]+a;

				}else {
				int a =  Math.abs(h[i]-h[i-1]);
				int b =  Math.abs(h[i]-h[i-2]);

				if(a>b) {
					dp[i] = dp[i-2]+b;
				}else {
					dp[i] = dp[i-1]+a;
				}
				}
			}

			System.out.println(dp[N-1]);

		}


	}


}
//  [cpp]
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	int dp[2], h[2] = {};
	dp[0] = 1e9;
	dp[1] = 1e9;

	int H = getint();
	int kotae = 0;
	rep(i, N - 1) {
		h[i & 1] = H;
		dp[i & 1] = kotae;
		H = getint();
		kotae = 1e9;
		chmin(kotae, dp[0] + abs(h[0] - H));
		chmin(kotae, dp[1] + abs(h[1] - H));
	}

	printf("%d", kotae);

	Would you please return 0;
}
//  [cpp]
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	int dp[3], h[3];
	dp[0] = 0;
	dp[1] = 1e9;
	dp[2] = 1e9;
	h[0] = getint();
	h[1] = getint();

	int k1 = 0;
	int k2 = 1;
	int k3 = 2;
	rep(i, N - 2) {
		h[k3] = getint();
		chmin(dp[k2], dp[k1] + abs(h[k1] - h[k2]));
		chmin(dp[k3], dp[k1] + abs(h[k1] - h[k3]));
		dp[k1] = 1e9;
		swap(k1, k2);
		swap(k2, k3);
	}
	chmin(dp[k2], dp[k1] + abs(h[k1] - h[k2]));

	printf("%d", dp[k2]);

	Would you please return 0;
}
//  [cpp]
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
      int n;
      cin>>n;
      vector<int> a(n);
      for(int i=0; i<n; i++)
        cin>>a[i];
      vector<int> dp(n);
      if(n==2) return abs(a[0]-a[1]);
      dp[0]=a[0];
      dp[1]=abs(a[0]-a[1]);
      for(int i=2; i<n; i++)
        dp[i]=min(abs(a[i]-a[i-1])+dp[i-1], abs(a[i-2]-a[i])+dp[i-2]);
      cout<<dp[n-1]<<endl;
      return 0;
    }
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0; i<n; i++)
    cin>>a[i];
  vector<int> dp(n);
  if(n==2) return abs(a[0]-a[1]);
  dp[0]=a[0];
  dp[1]=abs(a[0]-a[1]);
  for(int i=2; i<n; i++)
    dp[i]=min(abs(a[i]-a[i-1])+dp[i-1], abs(a[i-2]-a[i])+dp[i-2]);
  return dp[n-1];
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
int solve(vector<int>&a,int n){
    if(n==2)return abs(a[1]-a[0]);
    if(n<2) return 0;
    return min(abs(a[n-2]-a[n-1])+solve(a,n-1),abs(a[n-3]-a[n-1])+solve(a,n-2));
}
int main(){
    int n;
    cin>>n;
    vector<int>a;
    for(int i=0;i<n;i++){
        int s;cin>>s;a.push_back(s);
    }
    cout<<solve(a,n);
}
//  [c]
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>

int main(void){

    int n, k=2, *hs;
    long *C1;
    scanf("%d ", &n);

    hs = malloc(n * sizeof(int));
    C1 = malloc(n * sizeof(long));

    for(int c = getchar(), i = 0; i < n; c = getchar(), ++i){

        while(isspace(c)) c = getchar();
        int valor = 0;
        for(; c >= '0'; c = getchar()) valor = valor * 10 + c - '0';
        hs[i] = valor;
    }

    C1[0] = 0;
    int lim = k < n ? k : n;
    for(int i = 1; i < lim; ++i){

        int hi = hs[i];
        long minimo = LONG_MAX;

        for(int j = 0; j < i; ++j){

            int prueba = C1[j] + abs(hi - hs[j]);
            if(prueba < minimo) minimo = prueba;
        }

        C1[i] = minimo;
    }

    for(int i = k; i < n; ++i){

        int hi = hs[i];
        long minimo = LONG_MAX;

        for(int j = i - k; j < i; ++j){

            int prueba = C1[j] + abs(hi - hs[j]);
            if(prueba < minimo) minimo = prueba;
        }

        C1[i] = minimo;
    }

    printf("%li", C1[n - 1]);
}
//  [c]
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>

int main(void){

    int n, *hs;
    long *costs;
    scanf("%d\n", &n);

    const int k = 2;

    hs = malloc(n * sizeof(int));
    costs = malloc(n * sizeof(long));

    for(int c = getchar(), i = 0; i < n; c = getchar(), ++i){

        while(isspace(c)) c = getchar();
        int val = 0;
        for(; c >= '0'; c = getchar()) val = val * 10 + c - '0';
        hs[i] = val;
    }

    costs[0] = 0;
    int lim = k < n ? k : n;
    for(int i = 1; i < lim; ++i){

        int hi = hs[i];
        long min = LONG_MAX;
        for(int j = 0; j < i; ++j){

            int testing = costs[j] + abs(hi - hs[j]);
            if(testing < min) min = testing;
        }
        costs[i] = min;
    }

    for(int i = k; i < n; ++i){

        int hi = hs[i];
        long min = LONG_MAX;
        for(int j = i - k; j < i; ++j){

            int testing = costs[j] + abs(hi - hs[j]);
            if(testing < min) min = testing;
        }
        costs[i] = min;
    }

    printf("%li", costs[n - 1]);
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define NUM_MAX 100000
#define BUF_SIZE (NUM_MAX*7+50)

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
#ifdef BUF_SIZE
    char line[BUF_SIZE];
    char *tmpbuf = line;
    int i;
    if(!fgets(line, BUF_SIZE, stdin)) return -1;
    for(i = 0; i < size; i++) {
        char *tmp = strtok(tmpbuf, " ");
        arr[i] = strtol(tmp, NULL, 10);
        tmpbuf = NULL;
    }
#else
#error
#endif
    return 0;
}

#define min(a,b) ((a) > (b) ? (b) : (a))

int main(void) {
    int num = get_int();
    static int arr[NUM_MAX+1];
    static int dp[NUM_MAX+1];
    memset(dp, 0x3f, sizeof(int)*(NUM_MAX+1));
    fget_array(&arr[1], num);
    int i;
    dp[1] = 0;
    dp[2] = dp[1] + abs(arr[2] - arr[1]);
    for(i = 3; i <= num; i++) {
        dp[i] = min(dp[i], dp[i-1] + abs(arr[i]-arr[i-1]));
        dp[i] = min(dp[i], dp[i-2] + abs(arr[i]-arr[i-2]));
    }
    printf("%d\n", dp[num]);
    return 0;
}
//  [c]
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define MOD 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define fast ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define umll unordered_map<ll,ll>
#define mll map<ll,ll>
#define forr(i,p,n) for(ll i=p;i<(ll)n;i++)
#define fore(i,n,k) for(ll i=n-1;i>=k;i--)
#define MAXN 1000003
typedef long long ll;
using namespace std;
ll mult(ll a, ll b, ll p = MOD) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = MOD) {return (a % p + b % p) % p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD) {ll m0 = m; ll y = 0, x = 1; if (m == 1)return 0; while (a > 1) {ll q = a / m; ll t = m; m = a % m, a = t; t = y; y = x - q * y; x = t;} if (x < 0)x += m0; return x;}
using namespace __gnu_pbds;
typedef tree<ll, null_type, less< ll>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
void functiontosolve()
{
    ll n;
    cin >> n;
    ll a[n];
    forr(i, 0, n) cin >> a[i];
    ll dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    forr(i, 2, n) {
        dp[i] = min(dp[i - 1] + abs(a[i - 1] - a[i]), dp[i - 2] + abs(a[i - 2] - a[i]));
    }
    cout << dp[n - 1] << "\n";
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int test;
    test  = 1;
    forr(i, 1, test + 1) {
        functiontosolve();
    }
    return 0;
}
//  [c]
#include <stdio.h>
#int <math.h>
int H[10010];
int N;
int min(int a,int b){
  if(a>b){
    return b;
  }
  else{
    return a;
  }
}
int solve(int curr,int next){
  int cost = 0;
  curr--;
  next--;
  if(next==N){
    return 10000000000;
  }
  else{
    if(solve(curr,curr+1)<=solve(curr,curr+2)){
      cost = abs(H[curr] - H[curr+1]);
      }
      else{
        cost = abs(H[curr] - H[curr+2]);
      }
  }
  return cost;
}
    
  
int main(void){
  
  scanf("%d" , &N);
  int i = 0;
  for(i=0;i<N;i++){
    scanf("%d", &H[i]);
  }
  solve(1);
  
  
  return 0;
}
//  [c]
#include <stdio.h>
#define MIN(x, y) ((x) > (y) ? (y) : (x))
#define ABS(x) ((x) < 0 ? (-1*(x)) : (x))
int main()
{
  int n;
  scanf("%d",&n);
  int h[n];
  int i = 0;
  while (i < n)
  {
    scanf("%d",&h[i]);
    i++;
  }
  //一つ手前の足場までの最小値を記録し、それを利用して計算量を減らす
  i = 0;
  int dp[n];
  while (i < n)
  {
    dp[i] = 0;
    i++;
  }
  i = 0;
  dp[0] = 0;
  dp[1] = ABS(h[0] - h[1]);
  //printf("dp[1]:%d\n",dp[1]);
  if (n == 2)
  {
    printf("%d",dp[1]);
    return (0);
  }
  //i-1とi-2、足場iからコストの小さい方を選び、選んだ足場までのコストをそれに足す。
  if (ABS(h[2]-h[1]) < ABS(h[2]-h[0]))
    dp[2] = dp[1] + ABS(h[2]-h[1]);
  else
    dp[2] = dp[0] + ABS(h[2]-h[0]);
  if (n == 3)
  {
    printf("%d",dp[2]);
    return (0);
  }
  
  i = 3;
  int tmp;
  while (i < n)
  {
    //printf("i-1:%d\n",dp[i-1]);
    if (ABS(h[i]-h[i-1]) < ABS(h[i]-h[i-2]))
        dp[i] = dp[i-1] + ABS(h[i]-h[i-1]);
    else
        dp[i] = dp[i-2] + ABS(h[i]-h[i-2]);
    //printf("%d\n",tmp);
    //printf("h[i]-h[i-1]:%d h[i]-h[i-2]:%d\n",abs(h[i]-h[i-1]),abs(h[i]-h[i-2]));
    //printf("min:%d\n",min(abs(h[i]-h[i-1]),abs(h[i]-h[i-2])));
    //printf("i  :%d\n",dp[i]);
    i++;
  }
  printf("%d",dp[i-1]);
}
//  [javascript]
function Main(input) {
	input = input.split("\n");
	var n = parseInt(input[0], 10);	
  	l2=input[1].split(" ");
  	var h=new Array(n);
  	var cost=new Array(n);
  	for (var i=0; i<n; i++){
     h[i]= parseInt(l2[i], 10);
    }
  	cost[0]=0;
  	cost[1]=Math.abs(h[1]-h[0]);
  
  	for (var i=2; i<n; 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]));
    }
  
  	console.log('%d',cost[n-1]);
  }
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]


function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  tmp = input[1].split(" ");
  h = new Array(N);
  for(var i=0;i<N;i++){
    h[i]=parseInt(tmp[i]);
  }
  var mins=new Array(N).fill(Math.pow(10,9)+1);
  mins[0]=0;
  mins[1]=Math.abs(h[1]-h[0]);
  for(var i=2;i<N;i++){
    mins[i]=Math.min(mins[i-1]+Math.abs(h[i]-h[i-1]),mins[i-2]+Math.abs(h[i]-h[i-2]));
  }
  var ans = mins[N-1];
  console.log('%s', ans);
  return ans;
}
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  input = input.split("\n");
  const N = parseInt(input[0],10);
  const hn = input[1].split(' ').map((n) => {
    return parseInt(n, 10);
  });
  const h_max = Math.pow(10,9);
  console.log(dp(N,hn,h_max));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function dp(N,hn,h_max) {
  const dp = [];
  dp[0] = 0;
  for (var i = 1; i < N; i++) {
    dp.push(h_max);
    if (i === 1) {
      dp[i] = Math.min(dp[i],dp[i-1] + Math.abs(hn[i-1] - hn[i]))
    } else {
      dp[i] = Math.min(dp[i],dp[i-1] + Math.abs(hn[i-1] - hn[i]),dp[i-2] + Math.abs(hn[i-2] - hn[i]))
    }
  }
  return dp[N-1];
}
//  [javascript]
process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    
    main();    
});

function readline() {
    return inputString[currentLine++];
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = parseInt(a[i]);

    return a;
}

function main(){
    let [n,k] = ti(readline().split(' '));
    let h = ti(readline().split(' '));

    let dp = new Array(n);
    dp.fill(999999999999999);
    dp[0] = 0;
    for(let i = 0; i < n; i++){
        for(let j = 1; j < k+1; j++){
            if(i-j >= 0)
                dp[i] = Math.min(dp[i], Math.abs(h[i]-h[i-j]) + dp[i-j]);
            else
                break;
        }
    }

    console.log(dp[n-1]);
}
//  [javascript]
'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function getArray(str) {
    return str.split(' ').map(x => Number(x));
}

function getInt(str) {
    return Number(str);
}

function getStrArray(str) {
    return str.split(' ').map(x => x);
}
// ---------------------------------------



function main() {
    const len = getInt(readline());
    const a = getArray(readline());
    const dp = new Array(len);
    dp.fill(-1);
    dp[0] = 0;
    dp[1] = Math.abs(a[1] - a[0]);
    const x = getCost(len-1, a);
    console.log(dp[len-1]);


    function getCost(i) {
        if(a < 0) {
            return 0;
        }
        if (dp[i] !== -1) {
            return dp[i];
        }

        dp[i] = Math.min(
            getCost(i-1) + Math.abs(a[i] - a[i - 1]),
            getCost(i-2) + Math.abs(a[i] - a[i - 2]),
        );

        return dp[i];
    }
}
//  [javascript]
'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function getArray(str) {
    return str.split(' ').map(x => Number(x));
}

function getInt(str) {
    return Number(str);
}

function getStrArray(str) {
    return str.split(' ').map(x => x);
}
// ---------------------------------------



function main() {
    const len = getInt(readline());
    const a = getArray(readline());
    const dp = new Array(len);
    dp.fill(-1);
    dp[0] = 0;
    dp[1] = Math.abs(a[1] - a[0]);
    const x = getCost(len-1, a);
    console.log(dp[len-1]);


    function getCost(i, a) {
        if(a < 0) {
            return 0;
        }
        if (dp[i] !== -1) {
            return 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]),
        );

        return dp[i];
    }
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func chmin(a *int, b int) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}
func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func newLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	var n int
	n, _ = strconv.Atoi(newLine())
	h := make([]int, n+20)
	inputLine := strings.Split(newLine(), " ")
	for i, v := range inputLine {
		h[i], _ = strconv.Atoi(v)
	}
	dp := make([]int, n+20)
	for i := 0; i < n+20; i++ {
		dp[i] = math.MaxInt64
	}
	dp[0] = 0
	chmin(&dp[1], dp[0]+abs(h[1]-h[0]))
	for i := 2; i < n; i++ {
		chmin(&dp[i], dp[i-1]+abs(h[i]-h[i-1]))
		chmin(&dp[i], dp[i-2]+abs(h[i]-h[i-2]))
	}
	fmt.Println(dp[n-1])
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func smaller(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()
	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = ri()
	}
	dp := make([]int, len(h))
	dp[0] = 0
	dp[1] = abs(h[1] - h[0])
	for i := 2; i < len(h); i++ {
		dp[i] = smaller(abs(h[i]-h[i-1])+dp[i-1], abs(h[i]-h[i-2])+dp[i-2])
	}
	fmt.Println(dp[len(dp)-1])
}
//  [go]
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n,_ = strconv.Atoi(NextLine())
  return n
}
func NextIntArray() []int {
  var s []string = strings.Split(NextLine()," ")
  var n int = len(s)
  var a []int = make([]int,n)
  for i:=0;i<n;i++ {
    a[i],_ = strconv.Atoi(s[i])
  }
  return a
}

func main() {
  var n int = NextInt()
  var h []int = NextIntArray()
  var c []int = make([]int,n)
  c[0] = 0
  c[1] = abs(h[1]-h[0])
  for i:=2;i<n;i++ {
    c[i] = min(c[i-1]+abs(h[i]-h[i-1]),c[i-2]+abs(h[i]-h[i-2]))
  }
  fmt.Println(c[n-1])
}
func abs(n int) int {
  if n < 0 { return -n }
  return n
}
func min(n int,m int) int {
  if n < m { return n }
  return m
}
//  [go]
package main

import (
	"math"
)

func minPossibleTotalCost(n int, height []int) int {
	dp := make([]int, n)
	dp[0] = 0
	for i := 1; i < n; i++ {
		dp[i] = 1 << 32
	}
	for i := 0; i < n; i++ {
		for _, j := range []int{i + 1, i + 2} {
			if j < n {
				cost := int(math.Abs(float64(height[i] - height[j])))
				dp[j] = min(dp[j], cost+dp[i])
			}
		}
	}
	return dp[n-1]
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}
//  [go]
import (
	"math"
)

func solution(n int, height []int) int {
	dp := make([]int, n)
	dp[0] = 0
	for i := 1; i < n; i++ {
		dp[i] = 1 << 32
	}
	for i := 0; i < n; i++ {
		for _, j := range []int{i + 1, i + 2} {
			if j < n {
				cost := int(math.Abs(float64(height[i] - height[j])))
				dp[j] = min(dp[j], cost+dp[i])
			}
		}
	}
	return dp[n-1]
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}
//  [go]
import (
	"math"
)

func minPossibleTotalCost(n int, height []int) int {
	dp := make([]int, n)
	dp[0] = 0
	for i := 1; i < n; i++ {
		dp[i] = 1 << 32
	}
	for i := 0; i < n; i++ {
		for _, j := range []int{i + 1, i + 2} {
			if j < n {
				cost := int(math.Abs(float64(height[i] - height[j])))
				dp[j] = min(dp[j], cost+dp[i])
			}
		}
	}
	return dp[n-1]
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}
//  [ruby]
ashiba_num = gets.to_i
ashiba_cost = gets.split(' ').map(&:to_i)

dP = []
dP[0] = 0
dP[1] = (ashiba_cost[1] - ashiba_cost[0]).abs

range = 2..ashiba_num - 1 
range.each do |move|
    comp1 = dP[move - 1] + (ashiba_cost[move] - ashiba_cost[move - 1]).abs
    comp2 = dP[move - 2] + (ashiba_cost[move] - ashiba_cost[move - 2]).abs

    comp1 >= comp2 ? dP[move] = comp2 : dP[move] = comp1

end

p dP.last
//  [ruby]
N=gets.to_i
a=gets.split.map(&:to_i)
dp=[]
dp[0]=0
dp[1]=(a[0]-a[1]).abs
for i in 2..N-1
    b=dp[i-2]+(a[i-2]-a[i]).abs
    c=dp[i-1]+(a[i-1]-a[i]).abs
    dp[i]=b > c ? c : b
end
puts dp[N-1]
//  [ruby]
n = gets.to_i
h = gets.chomp.split(" ").map(&:to_i)

dp = Array.new(n, Float::INFINITY)
dp[0] = 0
dp[1] = (h[1] - h[0]).abs

for i in 2.. n - 1
    step1 = dp[i - 1] + (h[i] - h[i - 1]).abs
    step2 = dp[i - 2] + (h[i] - h[i - 2]).abs
    
    if step1 < step2
        dp[i] = step1
    else
        dp[i] = step2
    end
end

puts dp[n - 1]
//  [ruby]
N = gets.chomp.to_i
H = gets.chomp.split.map(&:to_i)

@dp = Array.new(N) { 0 }
(0...N).each do |i|
  if i == 0
   @dp[i] = 0
  puts [i, @dp[i]]
   next
  elsif i == 1
   @dp[i] = @dp[i-1] + (H[i-1] - H[i]).abs
  puts [i, @dp[i]]
   next
  else
    @dp[i] = [@dp[i-1] + (H[i-1] - H[i]).abs,
              @dp[i-2] + (H[i-2] - H[i]).abs].min
  puts [i, @dp[i]]
  end

end
//  [ruby]
	# A - Frog 1
# https://atcoder.jp/contests/dp/tasks/dp_a

N = gets.chomp.to_i
H = gets.chomp.split.map(&:to_i)

@memo = Array.new(N) {Array.new(H.reduce(:+)) { nil }}

# c そこまでのコスト
def solve(i, c)
  #p [i, c,  @memo[i][c] ]
  return @memo[i][c] unless @memo[i][c].nil?

  if i >= N-1
    @memo[i][c] = c
    return @memo[i][c]
  end

  if i >= N-2
    @memo[i][c] = solve(i+1, c + (H[i+1] - H[i]).abs)
    return @memo[i][c]
  end

  # when jump to i+1
  c1 = solve(i+1, c + (H[i+1] - H[i]).abs)
  # when jump to i+2
  c2 = solve(i+2, c + (H[i+2] - H[i]).abs)

  @memo[i][c] = [c1,c2].min
  return @memo[i][c]
end


puts solve(0, 0)
//  [ruby]
require 'pp'

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end

def min(a, b)
  return a < b ? a : b
end

n, hlist = gets_n_and_i_list
INF = 100000 #Float::INFINITY

dp = Array.new(n, INF)
dp[0] = 0

0.upto(n-1) do |i|
  if i + 1 < n
    diff1 = (hlist[i + 1] - hlist[i]).abs + dp[i]
    dp[i + 1] = min(diff1, dp[i+1])
  end

  if i + 2 < n
    diff2 = (hlist[i + 2] - hlist[i]).abs + dp[i]
    dp[i + 2] = min(diff2, dp[i+2])
  end

end

puts dp.last
//  [rust]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();
    let h = i.read_vec::<isize>(n);

    writeln!(o, "{}", solve(&h)).unwrap();
}
fn solve(h: &[isize]) -> isize {
    let mut c: [isize; 2] = [0, (h[0] - h[1]).abs()];

    for i in 2..h.len() {
        c = [
            c[1],
            min(
                c[0] + (h[i] - h[i - 2]).abs(),
                c[1] + (h[i] - h[i - 1]).abs(),
            ),
        ];
    }
    c[1]
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            self.read_line()
                .split(' ')
                .take(n)
                .map(|x| x.parse().ok().unwrap())
                .collect()
        }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}
//  [rust]

use std::collections::*;
use std::io;
use std::cmp::*;

fn main(){
    let t_cases = 1;
    for _ in 0..t_cases{
        solve();
    }
}

fn solve(){
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.clear();
    io::stdin().read_line(&mut buf).unwrap();
    let a = buf
                .trim()
                .split_whitespace()
                .map(|x| x.parse::<i32>().unwrap())
                .collect::<Vec<i32>>();
    let n = a.len();
    let mut dp = vec![10i32.pow(9)+7;n];
    dp[0] = 0;
    for i in 0..n{
        if i >= 1{
            dp[i] = min(dp[i],dp[i-1]+(a[i]-a[i-1]).abs());
        }
        if i >=2{
            dp[i] = min(dp[i],dp[i-2]+(a[i]-a[i-2]).abs());
        }
    }
    println!("{}",dp[n-1]);
}
//  [rust]
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;


fn main() {
    proconio::input! {
        n: usize,
        mut p: [isize;n],
        }
    let mut q= vec![0;1000000000000];
    q[1]=(p[1]-p[0]).abs();
    for i in 0..n-2 {
        q[i+1]=min((p[i+1]-p[i]).abs()+q[i],q[i+1]);
        q[i+2]=(p[i+2]-p[i]).abs()+q[i];
    }
    q[n-1]=min((p[n-2]-p[n-1]).abs()+q[n-2],q[n-1]);
    println!("{}",q[n-1]);

    // g[i] = min( g[i-1] + f[i-1], g[i-2] + f[i-2])
    //
    // g[i+1] = min( g[i+1], g[i] + f[i+1],)
    //
}
//  [rust]
#![allow(dead_code, unused_imports, deprecated)]
use std::cmp::{max, min, Reverse};
use std::collections::*;
use maplit::*;
use num::Integer;
use proconio::input;
use proconio::marker::*;
use proconio::fastout;

const INF : i64 = 1000000007;

#[fastout]
fn main() {
  input! {
    n : usize,
  };

  let mut dp = vec![vec![0usize; 3]; n];
  
  for i in 0..n {
    input! {
      a : usize, b : usize, c : usize,
    };
    
    if i == 0 {
      dp[0][0] = a;
      dp[0][1] = b;
      dp[0][2] = c;
    } else {
      dp[i][0] = a + max(dp[i - 1][1], dp[i - 1][2]);
      dp[i][1] = b + max(dp[i - 1][2], dp[i - 1][0]);
      dp[i][2] = c + max(dp[i - 1][0], dp[i - 1][1]);
    }
  }
  
  println!("{}", dp[n - 1].iter().max().unwrap());
}
//  [rust]
//use proconio::{input, fastout};
use proconio::input;
use std::cmp::min;

//#[fastout]
fn main() {
    input! {
        n: usize,
        h: [i32; n],
    }
    let mut dp = vec![0; n];
    let m = 2;
    dp[1] = (h[1] - h[0]).abs();
    for i in m..n {
        let mut dpi = dp[i - 1] + (h[i] - h[i - 1]).abs();
        for j in 1..(m + 1) {
            dpi = min(dpi, dp[i - j] + (h[i] - h[i - j]).abs());
        }
        dp[i] = dpi;
    }

    println!("{}", dp[n - 1]);
}
//  [swift]
let n = Int(readLine()!)
let arr = readLine()!.split(separator: " ").map({Int($0)!})

var costArr = [Int](repeating: 0, count: arr.count)
costArr[1] = abs(arr[0] - arr[1])

for i in 2 ..< arr.count {
    costArr[i] = min(costArr[i-1] + abs(arr[i] - arr[i-1]), costArr[i-2] + abs(arr[i] - arr[i-2]))
}
print(costArr.last!)
//  [swift]
import Foundation
//漸化式
//var fib = [Int](repeating: 0, count: 100)
//fib[0] = 1
//fib[1] = 1
//for i in 2 ..< 50 {
//    fib[i] = fib[i-1] + fib[i-2]
//    print(fib[i])
//}


let N = Int(readLine()!)!
let h_line = readLine()!.split(separator: " ").map({Int($0)!})

var dp = [Int](repeatElement(0, count: N))
var cost = 0
dp[0] = 0
dp[1] = abs(h_line[1] - h_line[0])
for i in 2 ..< h_line.count {
    dp[i] = min(abs(h_line[i] - h_line[i-1]) + dp[i-1], abs(h_line[i-2] - h_line[i]) + dp[i-2])
}
print(dp.last!)
//  [swift]
let N = Int(readLine()!)!
let h = readLine()!.split(separator: " ").map { Int($0)! }
var dp: [Int] = .init(repeating: Int.max, count: N)
dp[0] = 0
for i in 0..<N-1 {
  dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i+1] - h[i]))
  if i + 2 < N {
  	dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i+2] - h[i]))
  }
}
print(dp[N-1])
//  [swift]
import Foundation
//漸化式
//var fib = [Int](repeating: 0, count: 100)
//fib[0] = 1
//fib[1] = 1
//for i in 2 ..< 50 {
//    fib[i] = fib[i-1] + fib[i-2]
//    print(fib[i])
//}


let N = Int(readLine()!)!
let h_line = readLine()!.split(separator: " ").map({Int($0)!})

var dp = [Int](repeatElement(0, count: N))
var cost = 0
dp[0] = 0
dp[1] = abs(h_line[1] - h_line[0])
for i in 2 ..< h_line.count {
    dp[i] = min(abs(h_line[2] - h_line[1]) + dp[i-1], abs(h_line[2] - h_line[0]) + dp[i-2])
}
print(dp)
print(dp.last!)
//  [swift]
import Foundation
//漸化式
//var fib = [Int](repeating: 0, count: 100)
//fib[0] = 1
//fib[1] = 1
//for i in 2 ..< 50 {
//    fib[i] = fib[i-1] + fib[i-2]
//    print(fib[i])
//}


let N = Int(readLine()!)!
let h_line = readLine()!.split(separator: " ").map({Int($0)!})

var dp = [Int](repeatElement(0, count: 100))
var cost = 0
dp[0] = 0
dp[1] = h_line[1] - h_line[0]
for i in 2 ..< h_line.count {
    dp[i] = min(abs(h_line[2] - h_line[1]) + dp[i-1], abs(h_line[2] - h_line[0]) + dp[i-2])
}
print(dp.reduce(0, +))
//  [swift]
let n = Int(readLine()!)!
let h = readLine()!.split{$0 == " "}.map{Int($0)!}
var d = [Int](repeating: 0, count: n), c = d

func f(_ x: Int)->Int {
    if x <= 1 {
        return abs(h[x] - h[0])
    }
    if c[x] == 1 {
        return d[x]
    }
    c[x] = 1

    d[x] = min(f(x - 1) + abs(h[x] - h[x-1]), f(x - 2) + abs(h[x] - h[x-2]))
    return d[x]
}

print(f(n-1))