import scala.io.StdIn._
object Main extends App {
  val n = readInt()
  val points = Array.tabulate(n){_ ⇒
    val Array(x, y) = readLine.trim.split(' ').map(_.toInt)
    Point(x, y)
  }
  val memo = Array.tabulate(n){i ⇒ Array.fill(n - i){-1}}
  for (i ← 1 until n / 100) minTree(points, 0, i * 100)(memo)
  println(minTree(points, 0, n)(memo))
  def minTree(points: Array[Point], from: Int, until: Int)(implicit memo: Array[Array[Int]]): Int = {
    if (from + 1 == until) {
      0
    }else if (until - from == 2) {
      minTree(points(from), points(from + 1))
    }else {
      if (memo(from)(until - from - 1) < 0) {
        memo(from)(until - from - 1) = (from + 1 until until).map{mid ⇒ minTree(points, from, mid) + minTree(root(points, from, mid), root(points, mid, until)) + minTree(points, mid, until)}.min
      }
      memo(from)(until - from - 1)
    }
  }
  def minTree(a: Point, b: Point, c: Point): Int = {
    Math.min(minTree(root(a, b), c) + minTree(a, b), minTree(a, root(b, c)) + minTree(b, c))
  }
  def minTree(a: Point, b: Point): Int = {
    b.x - a.x + a.y - b.y
  }
  def root(points: Array[Point], from: Int, until: Int): Point = root(points(from), points(until - 1))
  def root(a: Point, b: Point): Point = {
    Point(a.x, b.y)
  }
}

case class Point(x: Int, y: Int)
