package main

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

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n, x0, y0 := getI(), getF(), getF()
  rMax := 0.0
  xy := make([][]float64, n)
  for i := range xy {
    x, y := getF(), getF()
    r := math.Hypot(x - x0, y - y0)
    if r > rMax {
      rMax = r
    }
    xy[i] = []float64{ x, y }
  }

  rMin := 1000.0 * 1000.0
  for i := range xy {
    j := (i + 1) % n
    x1, y1, x2, y2 := xy[i][0], xy[i][1], xy[j][0], xy[j][1]
    var r float64
    if x1 == x2 && y1 == y2 {
      r = math.Hypot(x1, y1)
    } else {
      dd := (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)
      t := ((x0 - x1) * (x2 - x1) + (y0 - y1) * (y2 - y1)) / dd
      //writer.WriteString(fmt.Sprintf("dd %f, t %f\n", dd, t))
      if t < 0.0 {
        r = math.Hypot(x1 - x0, y1 - y0)
      } else if t > 1.0 {
        r = math.Hypot(x2 - x0, y2 - y0)
      } else {
        x := x1 + t * (x2 - x1)
        y := y1 + t * (y2 - y1)
        r = math.Hypot(x - x0, y - y0)
      }
    }
    //writer.WriteString(fmt.Sprintf("(%f, %f) (%f, %f) %f\n\n",
    //    x1, y1, x2, y2, r))
    if r < rMin {
      rMin = r
    }
  }

  //writer.WriteString(fmt.Sprintf("%f %f\n", rMin, rMax))
  writer.WriteString(fmt.Sprintf("%.12f\n",
    (rMax * rMax - rMin * rMin) * math.Pi))
}

package main

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

type vertex struct {
    x float64
    y float64
}

type vertices []vertex

func dist(pfx, pfy float64, vi, vj *vertex) float64 {
    x1 := (*vi).x
    y1 := (*vi).y
    x2 := (*vj).x
    y2 := (*vj).y

    if x1 == x2 && y1 == y2 {
        return math.Hypot(x1, y1)
    }

    var h float64
    dd := (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)
    z := ((pfx - x1) * (x2 - x1) + (pfy - y1) * (y2 - y1)) / dd
    if z < 0.0 {
        h = math.Hypot(x1 - pfx, y1 - pfy)
    } else if z > 1.0 {
        h = math.Hypot(x2 - pfx, y2 - pfy)
    } else {
        hx := x1 + z * (x2 - x1)
        hy := y1 + z * (y2 - y1)
        h = math.Hypot(hx - pfx, hy - pfy)
    }
    return h
}

func main() {
    stin := bufio.NewReader(os.Stdin)
    var tmp []byte
    tmp,_ = stin.ReadBytes(' ')
    n,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
    tmp,_ = stin.ReadBytes(' ')
    px,_ := strconv.ParseFloat(string(bytes.Trim(tmp," ")), 64)
    tmp,_ = stin.ReadBytes('\n')
    py,_ := strconv.ParseFloat(string(bytes.Trim(tmp,"\n\r")), 64)
    //fmt.Printf("%v %v %v\n", n, px, py)

    var v vertices = make(vertices, n)
    minDistance := float64(1.0e18)
    maxDistance := float64(0.0)
    for i := 0; i < n; i++ {
        tmp,_ = stin.ReadBytes(' ')
        x,_ := strconv.ParseFloat(string(bytes.Trim(tmp," ")), 64)
        tmp,_ = stin.ReadBytes('\n')
        y,_ := strconv.ParseFloat(string(bytes.Trim(tmp,"\n\r")), 64)
        //fmt.Printf("%v %v\n", x, y)
        d := math.Hypot(px-x, py-y)
        if d > maxDistance {
            maxDistance = d
        }
        if d < minDistance {
            minDistance = d
        }
        v[i] = vertex{x:x, y:y}
    }
    //fmt.Printf("%v", v)

    for i := 0; i < n; i++ {
        j := (i + 1)%n
        h := dist(px, py, &v[i], &v[j])
        if h < minDistance {
            minDistance = h
        }
    }
    fmt.Printf("%.12f\n", (maxDistance*maxDistance - minDistance*minDistance) * math.Pi)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"math"
	"os"
)

const eps = 1e-6

type vec struct {
	x, y float64
}

func (a vec) add(b vec) vec     { return vec{a.x + b.x, a.y + b.y} }
func (a vec) sub(b vec) vec     { return vec{a.x - b.x, a.y - b.y} }
func (a vec) mul(k float64) vec { return vec{a.x * k, a.y * k} }
func (a vec) len2() float64     { return a.x*a.x + a.y*a.y }
func (a vec) dot(b vec) float64 { return a.x*b.x + a.y*b.y }
func (a vec) det(b vec) float64 { return a.x*b.y - a.y*b.x }

type line struct {
	p1, p2 vec
}

func (a vec) perpendicular(l line) line {
	return line{a, a.add(vec{l.p1.y - l.p2.y, l.p2.x - l.p1.x})}
}

func (a line) intersection(b line) vec {
	va, vb := a.p2.sub(a.p1), b.p2.sub(b.p1)
	k := vb.det(b.p1.sub(a.p1)) / vb.det(a.p2.sub(a.p1))
	return a.p1.add(va.mul(k))
}

func (a vec) onSeg(l line) bool {
	p1 := l.p1.sub(a)
	p2 := l.p2.sub(a)
	return math.Abs(p1.det(p2)) < eps && p1.dot(p2) < eps
}

func (a vec) disToSeg(l line) float64 {
	p := l.intersection(a.perpendicular(l))
	if !p.onSeg(l) {
		if l.p2.sub(l.p1).dot(p.sub(l.p1)) < -eps {
			p = l.p1
		} else {
			p = l.p2
		}
	}
	return a.sub(p).len2()
}

// github.com/EndlessCheng/codeforces-go
func Sol613A(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	var o vec
	Fscan(in, &n, &o.x, &o.y)
	minD2, maxD2 := 1e18, 0.0
	ps := make([]vec, n)
	for i := range ps {
		Fscan(in, &ps[i].x, &ps[i].y)
		ps[i] = ps[i].sub(o)
		if d2 := ps[i].len2(); d2 > maxD2 {
			maxD2 = d2
		}
	}
	ls := make([]line, n)
	for i := 0; i < n-1; i++ {
		ls[i] = line{ps[i], ps[i+1]}
	}
	ls[n-1] = line{ps[n-1], ps[0]}
	for _, l := range ls {
		if d2 := (vec{0, 0}).disToSeg(l); d2 < minD2 {
			minD2 = d2
		}
	}
	Fprintf(out, "%.18f", (maxD2-minD2)*math.Pi)
}

func main() {
	Sol613A(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"math"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func Sol613A(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	var ox, oy, x, y int64
	Fscan(in, &n, &ox, &oy)
	minD2, maxD2 := int64(1e18), int64(0)
	for i := 0; i < n; i++ {
		Fscan(in, &x, &y)
		x -= ox
		y -= oy
		d2 := x*x + y*y
		if d2 < minD2 {
			minD2 = d2
		}
		if d2 > maxD2 {
			maxD2 = d2
		}
	}
	Fprintf(out, "%.18f", float64(maxD2-minD2)*math.Pi)
}

func main() {
	Sol613A(os.Stdin, os.Stdout)
}

package main

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

type vertex struct {
    x float64
    y float64
}

type vertices []vertex

func dist(pfx, pfy float64, vi, vj *vertex) float64 {
    x1 := (*vi).x
    y1 := (*vi).y
    x2 := (*vj).x
    y2 := (*vj).y

    var h float64
    dd := (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)
    z := ((pfx - x1) * (x2 - x1) + (pfy - y1) * (y2 - y1)) / dd
    if z < 0.0 {
        h = math.Hypot(x1 - pfx, y1 - pfy)
    } else if z > 1.0 {
        h = math.Hypot(x2 - pfx, y2 - pfy)
    } else {
        hx := x1 + z * (x2 - x1)
        hy := y1 + z * (y2 - y1)
        h = math.Hypot(hx - pfx, hy - pfy)
    }
    return h
}

func main() {
    stin := bufio.NewReader(os.Stdin)
    var tmp []byte
    tmp,_ = stin.ReadBytes(' ')
    n,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
    tmp,_ = stin.ReadBytes(' ')
    px,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
    tmp,_ = stin.ReadBytes('\n')
    py,_ := strconv.Atoi(string(bytes.Trim(tmp,"\n\r")))
    //fmt.Printf("%v %v %v\n", n, px, py)

    var v vertices = make(vertices, n)
    minDistance := float64(1.0e18)
    var minDistanceVertex int = -1
    maxDistance := float64(0.0)
    for i := 0; i < n; i++ {
        tmp,_ = stin.ReadBytes(' ')
        x,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
        tmp,_ = stin.ReadBytes('\n')
        y,_ := strconv.Atoi(string(bytes.Trim(tmp,"\n\r")))
        //fmt.Printf("%v %v\n", x, y)
        d := math.Hypot(float64(px-x), float64(py-y))
        if d > maxDistance {
            maxDistance = d
        }
        if d < minDistance {
            minDistance = d
            minDistanceVertex = i
        }
        v[i] = vertex{x:float64(x), y:float64(y)}
    }
    //fmt.Printf("%v", v)

    i := minDistanceVertex
    j := minDistanceVertex - 1
    if j < 0 {
        j = n-1
    }
    hL := dist(float64(px), float64(py), &v[i], &v[j])
    if hL < minDistance {
        minDistance = hL
    }

    j = (minDistanceVertex + 1)%n
    hR := dist(float64(px), float64(py), &v[i], &v[j])
    if hR < minDistance {
        minDistance = hR
    }
    fmt.Printf("%f\n", math.Pi * (maxDistance*maxDistance - minDistance*minDistance))

}

package main

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

type vertex struct {
    x float64
    y float64
}

type vertices []vertex

func main() {
    stin := bufio.NewReader(os.Stdin)
    var tmp []byte
    tmp,_ = stin.ReadBytes(' ')
    n,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
    tmp,_ = stin.ReadBytes(' ')
    px,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
    tmp,_ = stin.ReadBytes('\n')
    py,_ := strconv.Atoi(string(bytes.Trim(tmp,"\n\r")))
    //fmt.Printf("%v %v %v\n", n, px, py)

    var v vertices = make(vertices, n)
    minDistance := float64(1.0e18)
    maxDistance := float64(0.0)
    for i := 0; i < n; i++ {
        tmp,_ = stin.ReadBytes(' ')
        x,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
        tmp,_ = stin.ReadBytes('\n')
        y,_ := strconv.Atoi(string(bytes.Trim(tmp,"\n\r")))
        //fmt.Printf("%v %v\n", x, y)
        d := math.Sqrt(float64((px-x)*(px-x) + (py-y)*(py-y)))
        if d > maxDistance {
            maxDistance = d
        }
        if d < minDistance {
            minDistance = d
        }
        v[i] = vertex{x:float64(x), y:float64(y)}
    }
    //fmt.Printf("%v", v)
    for i := 0; i < n-1; i++ {
        for j := i+1; j < n; j++ {
            pfx, pfy := float64(px), float64(py)
            x1 := v[i].x
            y1 := v[i].y
            x2 := v[j].x
            y2 := v[j].y

            var h float64
            dd := (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)
            z := ((pfx - x1) * (x2 - x1) + (pfy - y1) * (y2 - y1)) / dd
            if z < 0.0 {
                h = math.Hypot(x1 - pfx, y1 - pfy)
            } else if z > 1.0 {
                h = math.Hypot(x2 - pfx, y2 - pfy)
            } else {
                hx := x1 + z * (x2 - x1)
                hy := y1 + z * (y2 - y1)
                h = math.Hypot(hx - pfx, hy - pfy)
            }
            if h < minDistance {
                minDistance = h
            }
        }
    }
    fmt.Printf("%v\n", math.Pi * (maxDistance*maxDistance - minDistance*minDistance))

}

package main

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

type vertex struct {
    x float64
    y float64
}

type vertices []vertex

func dist(pfx, pfy float64, vi, vj *vertex) float64 {
    x1 := (*vi).x
    y1 := (*vi).y
    x2 := (*vj).x
    y2 := (*vj).y

    var h float64
    dd := (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)
    z := ((pfx - x1) * (x2 - x1) + (pfy - y1) * (y2 - y1)) / dd
    if z < 0.0 {
        h = math.Hypot(x1 - pfx, y1 - pfy)
    } else if z > 1.0 {
        h = math.Hypot(x2 - pfx, y2 - pfy)
    } else {
        hx := x1 + z * (x2 - x1)
        hy := y1 + z * (y2 - y1)
        h = math.Hypot(hx - pfx, hy - pfy)
    }
    return h
}

func main() {
    stin := bufio.NewReader(os.Stdin)
    var tmp []byte
    tmp,_ = stin.ReadBytes(' ')
    n,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
    tmp,_ = stin.ReadBytes(' ')
    px,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
    tmp,_ = stin.ReadBytes('\n')
    py,_ := strconv.Atoi(string(bytes.Trim(tmp,"\n\r")))
    //fmt.Printf("%v %v %v\n", n, px, py)

    var v vertices = make(vertices, n)
    minDistance := float64(1.0e18)
    var minDistanceVertex int = -1
    maxDistance := float64(0.0)
    for i := 0; i < n; i++ {
        tmp,_ = stin.ReadBytes(' ')
        x,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
        tmp,_ = stin.ReadBytes('\n')
        y,_ := strconv.Atoi(string(bytes.Trim(tmp,"\n\r")))
        //fmt.Printf("%v %v\n", x, y)
        d := math.Hypot(float64(px-x), float64(py-y))
        if d > maxDistance {
            maxDistance = d
        }
        if d < minDistance {
            minDistance = d
            minDistanceVertex = i
        }
        v[i] = vertex{x:float64(x), y:float64(y)}
    }
    //fmt.Printf("%v", v)

    i := minDistanceVertex
    j := minDistanceVertex - 1
    if j < 0 {
        j = n-1
    }
    hL := dist(float64(px), float64(py), &v[i], &v[j])
    if hL < minDistance {
        minDistance = hL
    }

    j = (minDistanceVertex + 1)%n
    hR := dist(float64(px), float64(py), &v[i], &v[j])
    if hR < minDistance {
        minDistance = hR
    }
    fmt.Printf("%.8f\n", math.Pi * (maxDistance*maxDistance - minDistance*minDistance))
}

package main

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

type vertex struct {
    x float64
    y float64
}

type vertices []vertex

func dist(pfx, pfy float64, vi, vj *vertex) float64 {
    x1 := (*vi).x
    y1 := (*vi).y
    x2 := (*vj).x
    y2 := (*vj).y

    var h float64
    dd := (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)
    z := ((pfx - x1) * (x2 - x1) + (pfy - y1) * (y2 - y1)) / dd
    if z < 0.0 {
        h = math.Hypot(x1 - pfx, y1 - pfy)
    } else if z > 1.0 {
        h = math.Hypot(x2 - pfx, y2 - pfy)
    } else {
        hx := x1 + z * (x2 - x1)
        hy := y1 + z * (y2 - y1)
        h = math.Hypot(hx - pfx, hy - pfy)
    }
    return h
}

func main() {
    stin := bufio.NewReader(os.Stdin)
    var tmp []byte
    tmp,_ = stin.ReadBytes(' ')
    n,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
    tmp,_ = stin.ReadBytes(' ')
    px,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
    tmp,_ = stin.ReadBytes('\n')
    py,_ := strconv.Atoi(string(bytes.Trim(tmp,"\n\r")))
    //fmt.Printf("%v %v %v\n", n, px, py)

    var v vertices = make(vertices, n)
    minDistance := float64(1.0e18)
    var minDistanceVertex int = -1
    maxDistance := float64(0.0)
    for i := 0; i < n; i++ {
        tmp,_ = stin.ReadBytes(' ')
        x,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
        tmp,_ = stin.ReadBytes('\n')
        y,_ := strconv.Atoi(string(bytes.Trim(tmp,"\n\r")))
        //fmt.Printf("%v %v\n", x, y)
        d := math.Hypot(float64(px-x), float64(py-y))
        if d > maxDistance {
            maxDistance = d
        }
        if d < minDistance {
            minDistance = d
            minDistanceVertex = i
        }
        v[i] = vertex{x:float64(x), y:float64(y)}
    }
    //fmt.Printf("%v", v)

    i := minDistanceVertex
    j := minDistanceVertex - 1
    if j < 0 {
        j = n-1
    }
    hL := dist(float64(px), float64(py), &v[i], &v[j])
    if hL < minDistance {
        minDistance = hL
    }

    j = (minDistanceVertex + 1)%n
    hR := dist(float64(px), float64(py), &v[i], &v[j])
    if hR < minDistance {
        minDistance = hR
    }
    fmt.Printf("%v\n", math.Pi * (maxDistance*maxDistance - minDistance*minDistance))

}

package main

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

type vertex struct {
    x float64
    y float64
}

type vertices []vertex

func dist(pfx, pfy float64, vi, vj *vertex) float64 {
    x1 := (*vi).x
    y1 := (*vi).y
    x2 := (*vj).x
    y2 := (*vj).y

    var h float64
    dd := (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)
    z := ((pfx - x1) * (x2 - x1) + (pfy - y1) * (y2 - y1)) / dd
    if z < 0.0 {
        h = math.Hypot(x1 - pfx, y1 - pfy)
    } else if z > 1.0 {
        h = math.Hypot(x2 - pfx, y2 - pfy)
    } else {
        hx := x1 + z * (x2 - x1)
        hy := y1 + z * (y2 - y1)
        h = math.Hypot(hx - pfx, hy - pfy)
    }
    return h
}

func main() {
    stin := bufio.NewReader(os.Stdin)
    var tmp []byte
    tmp,_ = stin.ReadBytes(' ')
    n,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
    tmp,_ = stin.ReadBytes(' ')
    px,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
    tmp,_ = stin.ReadBytes('\n')
    py,_ := strconv.Atoi(string(bytes.Trim(tmp,"\n\r")))
    //fmt.Printf("%v %v %v\n", n, px, py)

    var v vertices = make(vertices, n)
    minDistance := float64(1.0e18)
    var minDistanceVertex int = -1
    maxDistance := float64(0.0)
    for i := 0; i < n; i++ {
        tmp,_ = stin.ReadBytes(' ')
        x,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
        tmp,_ = stin.ReadBytes('\n')
        y,_ := strconv.Atoi(string(bytes.Trim(tmp,"\n\r")))
        //fmt.Printf("%v %v\n", x, y)
        d := math.Hypot(float64(px-x), float64(py-y))
        if d > maxDistance {
            maxDistance = d
        }
        if d < minDistance {
            minDistance = d
            minDistanceVertex = i
        }
        v[i] = vertex{x:float64(x), y:float64(y)}
    }
    //fmt.Printf("%v", v)

    i := minDistanceVertex
    j := minDistanceVertex - 1
    if j < 0 {
        j = n-1
    }
    hL := dist(float64(px), float64(py), &v[i], &v[j])
    if hL < minDistance {
        minDistance = hL
    }

    j = (minDistanceVertex + 1)%n
    hR := dist(float64(px), float64(py), &v[i], &v[j])
    if hR < minDistance {
        minDistance = hR
    }
    fmt.Printf("%.12f\n", (maxDistance*maxDistance - minDistance*minDistance) * math.Pi)
}

package main

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

type vertex struct {
    x float64
    y float64
}

type vertices []vertex

func dist(pfx, pfy float64, vi, vj *vertex) float64 {
    x1 := (*vi).x
    y1 := (*vi).y
    x2 := (*vj).x
    y2 := (*vj).y

    if x1 == x2 && y1 == y2 {
        return math.Hypot(x1, y1)
    }

    var h float64
    dd := (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)
    z := ((pfx - x1) * (x2 - x1) + (pfy - y1) * (y2 - y1)) / dd
    if z < 0.0 {
        h = math.Hypot(x1 - pfx, y1 - pfy)
    } else if z > 1.0 {
        h = math.Hypot(x2 - pfx, y2 - pfy)
    } else {
        hx := x1 + z * (x2 - x1)
        hy := y1 + z * (y2 - y1)
        h = math.Hypot(hx - pfx, hy - pfy)
    }
    return h
}

func main() {
    stin := bufio.NewReader(os.Stdin)
    var tmp []byte
    tmp,_ = stin.ReadBytes(' ')
    n,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
    tmp,_ = stin.ReadBytes(' ')
    px,_ := strconv.ParseFloat(string(bytes.Trim(tmp," ")), 64)
    tmp,_ = stin.ReadBytes('\n')
    py,_ := strconv.ParseFloat(string(bytes.Trim(tmp,"\n\r")), 64)
    //fmt.Printf("%v %v %v\n", n, px, py)

    var v vertices = make(vertices, n)
    minDistance := float64(1.0e18)
    var minDistanceVertex int = -1
    maxDistance := float64(0.0)
    for i := 0; i < n; i++ {
        tmp,_ = stin.ReadBytes(' ')
        x,_ := strconv.ParseFloat(string(bytes.Trim(tmp," ")), 64)
        tmp,_ = stin.ReadBytes('\n')
        y,_ := strconv.ParseFloat(string(bytes.Trim(tmp,"\n\r")), 64)
        //fmt.Printf("%v %v\n", x, y)
        d := math.Hypot(px-x, py-y)
        if d > maxDistance {
            maxDistance = d
        }
        if d < minDistance {
            minDistance = d
            minDistanceVertex = i
        }
        v[i] = vertex{x:x, y:y}
    }
    //fmt.Printf("%v", v)

    i := minDistanceVertex
    j := minDistanceVertex - 1
    if j < 0 {
        j = n-1
    }
    hL := dist(px, py, &v[i], &v[j])
    if hL < minDistance {
        minDistance = hL
    }

    j = (minDistanceVertex + 1)%n
    hR := dist(px, py, &v[i], &v[j])
    if hR < minDistance {
        minDistance = hR
    }
    fmt.Printf("%.12f\n", (maxDistance*maxDistance - minDistance*minDistance) * math.Pi)
}

package main

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

type vertex struct {
    x float64
    y float64
}

type vertices []vertex

func dist(pfx, pfy float64, vi, vj *vertex) float64 {
    x1 := (*vi).x
    y1 := (*vi).y
    x2 := (*vj).x
    y2 := (*vj).y

    if x1 == x2 && y1 == y2 {
        return math.Hypot(x1, y1)
    }

    var h float64
    dd := (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)
    z := ((pfx - x1) * (x2 - x1) + (pfy - y1) * (y2 - y1)) / dd
    if z < 0.0 {
        h = math.Hypot(x1 - pfx, y1 - pfy)
    } else if z > 1.0 {
        h = math.Hypot(x2 - pfx, y2 - pfy)
    } else {
        hx := x1 + z * (x2 - x1)
        hy := y1 + z * (y2 - y1)
        h = math.Hypot(hx - pfx, hy - pfy)
    }
    return h
}

func main() {
    stin := bufio.NewReader(os.Stdin)
    var tmp []byte
    tmp,_ = stin.ReadBytes(' ')
    n,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
    tmp,_ = stin.ReadBytes(' ')
    px,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
    tmp,_ = stin.ReadBytes('\n')
    py,_ := strconv.Atoi(string(bytes.Trim(tmp,"\n\r")))
    //fmt.Printf("%v %v %v\n", n, px, py)

    var v vertices = make(vertices, n)
    minDistance := float64(1.0e18)
    var minDistanceVertex int = -1
    maxDistance := float64(0.0)
    for i := 0; i < n; i++ {
        tmp,_ = stin.ReadBytes(' ')
        x,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
        tmp,_ = stin.ReadBytes('\n')
        y,_ := strconv.Atoi(string(bytes.Trim(tmp,"\n\r")))
        //fmt.Printf("%v %v\n", x, y)
        d := math.Hypot(float64(px-x), float64(py-y))
        if d > maxDistance {
            maxDistance = d
        }
        if d < minDistance {
            minDistance = d
            minDistanceVertex = i
        }
        v[i] = vertex{x:float64(x), y:float64(y)}
    }
    //fmt.Printf("%v", v)

    i := minDistanceVertex
    j := minDistanceVertex - 1
    if j < 0 {
        j = n-1
    }
    hL := dist(float64(px), float64(py), &v[i], &v[j])
    if hL < minDistance {
        minDistance = hL
    }

    j = (minDistanceVertex + 1)%n
    hR := dist(float64(px), float64(py), &v[i], &v[j])
    if hR < minDistance {
        minDistance = hR
    }
    fmt.Printf("%.12f\n", (maxDistance*maxDistance - minDistance*minDistance) * math.Pi)
}

package main

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

type vertex struct {
    x float64
    y float64
}

type vertices []vertex

func main() {
    stin := bufio.NewReader(os.Stdin)
    var tmp []byte
    tmp,_ = stin.ReadBytes(' ')
    n,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
    tmp,_ = stin.ReadBytes(' ')
    px,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
    tmp,_ = stin.ReadBytes('\n')
    py,_ := strconv.Atoi(string(bytes.Trim(tmp,"\n\r")))
    //fmt.Printf("%v %v %v\n", n, px, py)

    var v vertices = make(vertices, n)
    minDistance := float64(1.0e18)
    maxDistance := float64(0.0)
    for i := 0; i < n; i++ {
        tmp,_ = stin.ReadBytes(' ')
        x,_ := strconv.Atoi(string(bytes.Trim(tmp," ")))
        tmp,_ = stin.ReadBytes('\n')
        y,_ := strconv.Atoi(string(bytes.Trim(tmp,"\n\r")))
        //fmt.Printf("%v %v\n", x, y)
        d := math.Sqrt(float64((px-x)*(px-x) + (py-y)*(py-y)))
        if d > maxDistance {
            maxDistance = d
        }
        if d < minDistance {
            minDistance = d
        }
        v[i] = vertex{x:float64(x), y:float64(y)}
    }
    //fmt.Printf("%v", v)

    fmt.Printf("%v\n", math.Pi * (maxDistance*maxDistance - minDistance*minDistance))

}


package main

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

func main() {
	n := ScanInt()
	givenArray := ScanInt64Slice(n)
	t := 0
	moves := int64(0)

	for i := 0; i < n - 1; i++ {
		for float64(i)+math.Pow(2, float64(t)) < float64(n) {
			t++
		}
		t -= 1
		moves += givenArray[i]
		givenArray[int(float64(i)+ math.Pow(2, float64(t)))] += givenArray[i]
		P(moves)
	}

	close(O)
	oWg.Wait()
}

/*********************** I/O ***********************/

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

func main() {
	n := ScanInt()
	a := ScanIntSlice(n)
	move := int64(0)
	for i := 0; i < n-1; i++ {
		t := get2(i, n)
		move += int64(a[i])
		a[i+t] += a[i]
		P(move)
	}

	close(O)
	oWg.Wait()
}

func get2(k, n int) int {
	x := 1
	for (x<<1 + k + 1) <= n {
		x <<= 1
	}
	return x
}

/*********************** I/O ***********************/

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

func main() {
	n := ScanInt()
	a := ScanIntSlice(n)
	ka := make([]int, n)
	ka[0] = a[0]
	t := get2(0, n)
	a[t] += a[0]

	for k := 1; k < n-1; k++ {
		ka[k] += ka[k-1] + a[k]
		t := get2(k, n)
		a[t] += a[k]
		a[k] = 0
	}

	for i := 0; i < len(ka); i++ {
		P(ka[i])
	}
	close(O)
	oWg.Wait()
}

func get2(k, n int) int {
	x := 1
	for (x + k) <= n {
		if (x<<1 + k) < n {
			x <<= 1
		} else {
			break
		}
	}
	return x
}

/*********************** I/O ***********************/

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

func main() {
	n := ScanInt()
	givenArray := ScanIntSlice(n)
	t := 0
	moves := 0

	for i := 0; i < n-1; i++ {
		for float64(i)+math.Pow(2, float64(t)) < float64(n) {
			t++
		}
		t--
		moves += givenArray[i]
		givenArray[int(float64(i)+ math.Pow(2, float64(t)))] = givenArray[int(float64(i)+ math.Pow(2, float64(t)))] + givenArray[i]
		P(abs(int64(moves)))
	}

	close(O)
	oWg.Wait()
}

/*********************** I/O ***********************/

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

func main() {
	n := ScanInt()
	givenArray := ScanIntSlice(n)
	t := 0
	moves := 0

	for i := 0; i < n-1; i++ {
		for float64(i)+math.Pow(2, float64(t)) < float64(n) {
			t++
		}
		t--
		moves += givenArray[i]
		givenArray[int(float64(i)+ math.Pow(2, float64(t)))] = givenArray[int(float64(i)+ math.Pow(2, float64(t)))] + givenArray[i]
		P(moves)
	}

	close(O)
	oWg.Wait()
}

/*********************** I/O ***********************/

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

func main() {
	n := ScanInt()
	n--
	givenArray := ScanIntSlice(n)
	t := 0
	moves := 0

	for i := 0; i < n; i++ {
		for float64(i)+math.Pow(2, float64(t)) < float64(n) {
			t++
		}
		t--
		moves += givenArray[i]
		givenArray[int(float64(i)+ math.Pow(2, float64(t)))] += givenArray[i]
		P(moves)
	}

	close(O)
	oWg.Wait()
}

/*********************** I/O ***********************/

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

func main() {
	n := ScanInt()
	givenArray := ScanIntSlice(n)
	t := 0
	moves := 0

	for i := 0; i < n; i++ {
		if i == n - 1{
			break
		}
		for float64(i)+math.Pow(2, float64(t)) < float64(n) {
			t++
		}
		t -= 1
		moves += givenArray[i]
		givenArray[int(float64(i)+ math.Pow(2, float64(t)))] += givenArray[i]
		P(moves)
	}

	close(O)
	oWg.Wait()
}

/*********************** I/O ***********************/

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

func main() {
	n := ScanInt()
	givenArray := ScanIntSlice(n)
	t := 0
	moves := 0

	for i := 0; i < n-1; i++ {
		for float64(i)+math.Pow(2, float64(t)) < float64(n) {
			t++
		}
		t -= 1
		moves += givenArray[i]
		givenArray[int(float64(i)+ math.Pow(2, float64(t)))] += givenArray[i]
		P(moves)
	}

	close(O)
	oWg.Wait()
}

/*********************** I/O ***********************/

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}


package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)

func main() {
    var n, l , a int
    fmt.Fscanln(reader, &n, &l, &a)
    var prev11, prev12, prev21, prev22, nbreaks int
    for i := 0; i < n; i++ {
        fmt.Fscanln(reader, &prev21, &prev22)
	ttrest := prev21 - (prev11 + prev12)
	nbreaks += ttrest / a
	prev11 = prev21
	prev12 = prev22
    }
    ttrest := l - (prev11 + prev12)
    nbreaks += ttrest / a
    fmt.Println(nbreaks)
}

package main

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

func main() {
	var n, l, a int
	var t [100000 + 5]int
	var s [100000 + 5]int
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d %d\n", &n, &l, &a)
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%d %d\n", &t[i], &s[i])
	}
	now := 0
	ans := 0
	for i := 0; i < n; i++ {
		ans += ((t[i] - now) / a)
		now = t[i] + s[i]
	}
	ans += ((l - now) / a)
	fmt.Println(ans)
}

package main

import (
	"bufio"
	"math"
	"os"
	"strconv"
	"sync"
)

const (
	MAX_INT int64 = math.MaxInt64
	MIN_INT int64 = math.MinInt64
)

//3 13 3
//0 5
//7 2
//9 2

func main() {
	ans := int64(0)
	n, L, a := ScanInt64(), ScanInt64(), ScanInt64()

	currTime := int64(0)
	for i := int64(0); i < n; i++ {
		ti, li := ScanInt64(), ScanInt64()

		//if ti-currTime > a {
		ans += ((ti - currTime) / a)
		//}
		currTime = ti + li
	}

	ans += (L - currTime) / a

	out <- iToS(ans)

	close(out)
	outWg.Wait()
}

/*********************** I/O ***********************/

var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup

func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(writer *bufio.Writer) {
		defer outWg.Done()
		defer writer.Flush()

		for line := range out {
			writer.WriteString(line + "\n")
		}
	}(writer)
}

func ScanWord() string {
	in.Scan()
	return in.Text()
}

func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}

func ScanInt64() int64 {
	intStr := ScanWord()
	i, err := strconv.ParseInt(intStr, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func Max(args ...int64) int64 {
	maxVal := MIN_INT
	for _, v := range args {
		if v > maxVal {
			maxVal = v
		}
	}
	return maxVal
}

func Min(args ...int64) int64 {
	minVal := MAX_INT
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
	}
	return minVal
}

func LCM(a, b int64) int64 {
	return a / GCD(a, b) * b
}

func GCD(a, b int64) int64 {
	if (a == 0) {
		return b
	}
	return GCD(b%a, a)
}

func iToS(v int64) string {
	return strconv.FormatInt(v, 10)
}

package main

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

func main() {

	buf := bufio.NewReader(os.Stdin)
	var n, endT, termT int
	fmt.Fscanf(buf, "%d %d %d\n", &n, &endT, &termT)

	var freeStart, freeEnd int // [freeStart, freeEnd)

	termCnt := 0
	for i := 0; i < n; i++ {
		var t, l int
		fmt.Fscanf(buf, "%d %d\n", &t, &l)
		freeEnd = t

		termCnt += ((freeEnd - freeStart) / termT)

		freeStart = t + l
	}
	termCnt += ((endT - freeStart) / termT)

	fmt.Println(termCnt)
}

package main

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

func main() {
	n, l, a, e, scanner := 0, 0, 0, 0, bufio.NewScanner(os.Stdin)
	fmt.Scan(&n, &l, &a)
	q := make([][2]int, n)
	scanner.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		scanner.Scan()
		q[i][0], _ = strconv.Atoi(scanner.Text())
		scanner.Scan()
		q[i][1], _ = strconv.Atoi(scanner.Text())
	}

	total := 0
	for i := 0; i < n; i++ {
		total += (q[i][0] - e) / a
		e = q[i][0] + q[i][1]
	}
	total += (l - e) / a

	fmt.Println(total)
}

package main

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

func main() {
	n, l, a, e, scanner := 0, 0, 0, 0, bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	fmt.Scan(&n, &l, &a)
	q := make([][2]int, n)
	for i := 0; i < n; i++ {
		scanner.Scan()
		q[i][0], _ = strconv.Atoi(scanner.Text())
		scanner.Scan()
		q[i][1], _ = strconv.Atoi(scanner.Text())
	}

	total := 0
	for i := 0; i < n; i++ {
		total += (q[i][0] - e) / a
		e = q[i][0] + q[i][1]
	}
	total += (l - e) / a

	fmt.Println(total)
}

package main

import (
	"bufio"
	"os"
	"fmt"
)
var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }
func println(a ...interface{}) { fmt.Fprintln(writer, a...) }
func scanln(a ...interface{}) { fmt.Fscanln(reader, a...) }

func main() {
	defer writer.Flush()
	var n,d,a int
	scanln(&n,&d,&a)
	var s []int
	r := 0
	for i:=0;i<n;i++ {
		var t,l int
		scanln(&t,&l)
		s = append(s, t - r)
		r = t + l
	}
	s = append(s,d - r)
	k := 0
	for _,i := range(s){
		k += i/a
	}

	fmt.Println(k)
}

package main

import (
	"bufio"
	"math"
	"os"
	"strconv"
	"sync"
)

const (
	MAX_INT int64 = math.MaxInt64
	MIN_INT int64 = math.MinInt64
)

//3 11 1
//0 5
//5 8
//8 11

func main() {
	ans := int64(0)
	n, L, a := ScanInt64(), ScanInt64(), ScanInt64()
	customerServiceTime := int64(0)

	for i := int64(0); i < n; i++ {
		ti, li := ScanInt64(), ScanInt64()
		if ti == int64(0) {

		}
		customerServiceTime += li
	}

	ans = Max((L - customerServiceTime) / a, 0)

	out <- iToS(ans)

	close(out)
	outWg.Wait()
}

/*********************** I/O ***********************/

var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup

func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(writer *bufio.Writer) {
		defer outWg.Done()
		defer writer.Flush()

		for line := range out {
			writer.WriteString(line + "\n")
		}
	}(writer)
}

func ScanWord() string {
	in.Scan()
	return in.Text()
}

func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}

func ScanInt64() int64 {
	intStr := ScanWord()
	i, err := strconv.ParseInt(intStr, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func Max(args ...int64) int64 {
	maxVal := MIN_INT
	for _, v := range args {
		if v > maxVal {
			maxVal = v
		}
	}
	return maxVal
}

func Min(args ...int64) int64 {
	minVal := MAX_INT
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
	}
	return minVal
}

func LCM(a, b int64) int64 {
	return a / GCD(a, b) * b
}

func GCD(a, b int64) int64 {
	if (a == 0) {
		return b
	}
	return GCD(b%a, a)
}

func iToS(v int64) string {
	return strconv.FormatInt(v, 10)
}

package main

import (
	"bufio"
	"math"
	"os"
	"strconv"
	"sync"
)

const (
	MAX_INT int64 = math.MaxInt64
	MIN_INT int64 = math.MinInt64
)

func main() {
	ans := int64(0)
	n, L, a := ScanInt64(), ScanInt64(), ScanInt64()
	customerServiceTime := int64(0)

	for i := int64(0); i < n; i++ {
		ti, li := ScanInt64(), ScanInt64()
		if ti == int64(0) {

		}
		customerServiceTime += li
	}

	ans = (L - customerServiceTime) / a

	out <- iToS(ans)

	close(out)
	outWg.Wait()
}

/*********************** I/O ***********************/

var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup

func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(writer *bufio.Writer) {
		defer outWg.Done()
		defer writer.Flush()

		for line := range out {
			writer.WriteString(line + "\n")
		}
	}(writer)
}

func ScanWord() string {
	in.Scan()
	return in.Text()
}

func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}

func ScanInt64() int64 {
	intStr := ScanWord()
	i, err := strconv.ParseInt(intStr, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func Max(args ...int64) int64 {
	maxVal := MIN_INT
	for _, v := range args {
		if v > maxVal {
			maxVal = v
		}
	}
	return maxVal
}

func Min(args ...int64) int64 {
	minVal := MAX_INT
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
	}
	return minVal
}

func LCM(a, b int64) int64 {
	return a / GCD(a, b) * b
}

func GCD(a, b int64) int64 {
	if (a == 0) {
		return b
	}
	return GCD(b%a, a)
}

func iToS(v int64) string {
	return strconv.FormatInt(v, 10)
}

package main

import "fmt"

func main() {
	var n, endT, termT int
	fmt.Scanf("%d%d%d ", &n, &endT, &termT)

	var freeStart, freeEnd int // [freeStart, freeEnd)
	if 1 <= n {
		fmt.Scanf("%d%d ", &freeStart, &freeEnd)
		freeStart += freeEnd
	}

	termCnt := 0
	for i := 1; i < n; i++ {
		var t, l int
		fmt.Scanf("%d%d ", &t, &l)
		freeEnd = t

		termCnt += (freeEnd - freeStart) / termT

		freeStart = t + l
	}
	termCnt += (endT - freeStart) / termT

	fmt.Println(termCnt)
}

package main

import "fmt"

func main() {
	var n, endT, termT int
	fmt.Scanf("%d %d %d\n", &n, &endT, &termT)

	var freeStart, freeEnd int // [freeStart, freeEnd)
	if 1 <= n {
		fmt.Scanf("%d %d\n", &freeStart, &freeEnd)
		freeStart += freeEnd
	}

	termCnt := 0
	for i := 1; i < n; i++ {
		var t, l int
		fmt.Scanf("%d %d\n", &t, &l)
		freeEnd = t

		termCnt += (freeEnd - freeStart) / termT

		freeStart = t + l
	}
	termCnt += (endT - freeStart) / termT

	fmt.Println(termCnt)
}

package main

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

func main() {

	buf := bufio.NewReader(os.Stdin)
	var n, endT, termT int
	fmt.Fscanf(buf, "%d %d %d\n", &n, &endT, &termT)

	var freeStart, freeEnd int // [freeStart, freeEnd)
	if 1 <= n {
		fmt.Fscanf(buf, "%d %d\n", &freeStart, &freeEnd)
		freeStart += freeEnd
	}

	termCnt := 0
	for i := 1; i < n; i++ {
		var t, l int
		fmt.Fscanf(buf, "%d %d\n", &t, &l)
		freeEnd = t

		termCnt += ((freeEnd - freeStart) / termT)

		freeStart = t + l
	}
	termCnt += ((endT - freeStart) / termT)

	fmt.Println(termCnt)
}

package main

import "fmt"

func main() {
	var n, endT, termT int
	fmt.Scanf("%d%d%d", &n, &endT, &termT)

	var freeStart, freeEnd int // [freeStart, freeEnd)
	if 1 <= n {
		fmt.Scanf("%d%d", &freeStart, &freeEnd)
		freeStart += freeEnd
	}

	termCnt := 0
	for i := 1; i < n; i++ {
		var t, l int
		fmt.Scanf("%d%d", &t, &l)
		freeEnd = t

		termCnt += (freeEnd - freeStart) / termT

		freeStart = t + l
	}
	termCnt += (endT - freeStart) / termT

	fmt.Println(termCnt)
}

package main

import "fmt"

func main() {
	var n, endT, termT int
	fmt.Scanf("%d %d %d\n", &n, &endT, &termT)

	var freeStart, freeEnd int // [freeStart, freeEnd)
	if 1 <= n {
		fmt.Scanf("%d %d\n", &freeStart, &freeEnd)
		freeStart += freeEnd
	}

	termCnt := 0
	for i := 1; i < n; i++ {
		var t, l int
		fmt.Scanf("%d %d\n", &t, &l)
		freeEnd = t

		termCnt += ((freeEnd - freeStart) / termT)

		freeStart = t + l
	}
	termCnt += ((endT - freeStart) / termT)

	fmt.Println(termCnt)
}

package main

import "fmt"

func main() {
	var n, endT, termT int
	fmt.Scanf("%d %d %d ", &n, &endT, &termT)

	var freeStart, freeEnd int // [freeStart, freeEnd)
	if 1 <= n {
		fmt.Scanf("%d %d ", &freeStart, &freeEnd)
		freeStart += freeEnd
	}

	termCnt := 0
	for i := 1; i < n; i++ {
		var t, l int
		fmt.Scanf("%d %d ", &t, &l)
		freeEnd = t

		termCnt += (freeEnd - freeStart) / termT

		freeStart = t + l
	}
	termCnt += (endT - freeStart) / termT

	fmt.Println(termCnt)
}


package main

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

/*
4
3
1 3 4
5
1 2 5 7 4
1
1
3
69 6969 696969
---
1
3
0
696966
=========
1
5
3 4 6 2 10
---
5 -> 1 1 3 4 1 6 2 1 1 10
*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	bld := strings.Builder{}

	var t int
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		var n int
		scanf("%d\n", &n)

		insertCnt := 0

		idx := 1

		for i := 1; i <= n; i++ {
			var num int
			scanf("%d", &num)

			diff := num - idx
			if diff > 0 {
				insertCnt += diff
				idx += diff
			}

			idx++
		}
		scanf("\n")

		fmt.Fprintln(&bld, insertCnt)
	}

	printf("%s", bld.String())
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

//goland:noinspection GoUnusedType
type pair struct {
	fst rune
	snd int
}

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//goland:noinspection GoUnusedFunction
func isPrime(n int) bool {
	if n == 2 || n == 3 {
		return true
	}

	if n <= 1 || n%2 == 0 || n%3 == 0 {
		return false
	}

	for i := 5; i*i <= n; i += 6 {
		if n%i == 0 || n%(i+2) == 0 {
			return false
		}
	}

	return true
}

package main

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

func Max(arg ...int) int {
	m := arg[0]
	for _, v := range arg {
		if v > m {
			m = v
		}
	}
	return m
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		n := 0
		fmt.Fscan(f, &n)
		p, ans := 0, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &p)
			ans = Max(ans, p-j-1)
		}
		fmt.Fprintln(w, ans) // No idea why previous solution fails. Some missed corner case.
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
// 	redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		A()
	}
}

func A() {
	var n int
	scan(&n)
	var a = make([]int, n)
	for i := range a {
		scan(&a[i])
	}
	max := func(i, j int) int {
		if i > j {
			return i
		}
		return j
	}
	var ans int
	for i, v := range a {
		ans = max(ans, v-i-1)
	}
	printf("%v\n", ans)
}

func solve() {
	var n int
	scan(&n)
	var g = make([][]int, n)
	for i := 0; i < n-1; i++ {
		var u, v int
		scan(&u, &v)
		u--
		v--
		g[u] = append(g[u], v)
		g[v] = append(g[v], u)
	}

	var (
		color     = make([]int, n)
		colorSize = [2]int{}
		bicolor   func(u, c int)
	)
	for i := range color {
		color[i] = -1
	}
	bicolor = func(u, c int) {
		if color[u] != -1 {
			return
		}
		color[u] = c
		colorSize[c]++
		for _, v := range g[u] {
			bicolor(v, c^1)
		}
	}
	bicolor(0, 0)

}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
		}
		var tally int
		for j:=0;j<n;j++{
			if list[j] > j+1 {
				if list[j] - (j+1) > tally {
					tally=list[j]-(j+1)
				}
			}
		}
		fmt.Fprintln(out,tally)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		var n int64
		fmt.Fscan(in, &n)

		var shift int64
		for i := int64(0); i < n; i++ {
			var v int64
			fmt.Fscan(in, &v)

			if v > i+1 && v-i-1 > shift {
				shift = v - i - 1
			}
		}
		fmt.Fprintln(out, shift)
	}
}

package main

import (
	"fmt"
)

func getInt(p *int) {
	for {
		_, err := fmt.Scanf("%d", p)
		if err == nil {
			break
		}
	}
}

func proc() {
	var n, x int
	k := 0
	ans := 0
	getInt(&n)
	for j := 1; j <= n; j++ {
		k++
		getInt(&x)
		if x > k {
			ans += x - k
			k = x
		}
	}
	fmt.Println(ans)
}

func main() {
	var t int = 0
	getInt(&t)
	for i := 0; i < t; i++ {
		proc()
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"time"
)

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MINN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func MAXX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

func Union(a, b []int) []int {
	m := make(map[int]bool)

	for _, item := range a {
		m[item] = true
	}

	for _, item := range b {
		if _, ok := m[item]; !ok {
			a = append(a, item)
		}
	}
	return a
}

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

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)
	for o := 0; o < t; o++ {

		var n int
		fmt.Fscan(input, &n)

		B := make([]int, 1)
		for i := 1; i <= n; i++ {
			var q int
			fmt.Fscan(input, &q)
			if q > i {
				B = append(B, q-i)
			}
		}
		sort.Ints(B)
		qq := len(B)
		fmt.Println(B[qq-1])
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
var T, N int
var A int

func main() {
	defer out.Flush()

	fmt.Fscan(in, &T)
	var ans int
	for ; T > 0; T-- {
		fmt.Fscan(in, &N)
		ans = 0
		for i := 0; i < N; i++ {
			fmt.Fscan(in, &A)
			if v := A - i - 1; v > ans {
				ans = v
			}
		}
		fmt.Fprintln(out, ans)
	}
}

package main

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

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		readInt(reader)
		a := readArrayInt64(reader)

		var sum int64 = 0
		for i, v := range a {
			if v > int64(i+1) + sum {
				sum += v - (int64(i+1)+sum)
			}
		}

		fmt.Fprintln(writer, sum)

		t--
	}

	writer.Flush()
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

package main

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

type CF1604A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1604A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1604A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1604A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1604A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1604A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1604A
Date: 14/01/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1604/A
Problem: CF1604A
**/
func (in *CF1604A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		index := 1
		ans := 0
		for i := 0; i < n; i++ {
			num := in.NextInt()
			if index < num {
				ans += num - index
				index += num - index
			}
			index++
		}
		fmt.Println(ans)
	}
}

func NewCF1604A(r *bufio.Reader) *CF1604A {
	return &CF1604A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1604A(bufio.NewReader(os.Stdin)).Run()
}

package main

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

var n int
var a []int

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int

	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(r, &n)

		a = make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Fscan(r, &a[j])
		}

		ans := solve()

		fmt.Println(ans)
	}
}

func solve() int {
	var ans int

	for i := 0; i < n; i++ {
		if a[i] > i + 1 {
			diff := a[i] - i - 1
			ans = max(ans, diff)
		}
	}
	return ans
}

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

package main

import "fmt"

func max(a int,b int )  int{
	if a>b {
		return  a
	}
	return b

}
func main() {
	var t int
	for fmt.Scan(&t);t>0;t--{
		var n int
		fmt.Scan(&n)
		ans:=0
		for i:=1;i<=n;i++ {
			var num int
			fmt.Scan(&num)
			num=max(num-i,0)
			ans=max(ans,num)
		}
		fmt.Println(ans)
	}

}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	t, n   int
)

func solve(n int, a []int) int {
	var x int
	for i, v := range a {
		if x < v-i-1 {
			x = v - i - 1
		}
	}
	return x
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		fmt.Println(solve(n, a))
	}
}

package main

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

var inp = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	defer out.Flush()
	var t, n int16
	var a, v, c int32
	fmt.Fscan(inp, &t)
	for ; t > 0; t-- {
		fmt.Fscan(inp, &n)
		c, v = 0, 1
		for ; n > 0; n-- {
			fmt.Fscan(inp, &a)
			if a > v {
				c += a - v
				v = a
			}
			v++
		}
		fmt.Fprintf(out, "%v\n", c)
	}
}

package main

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

var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assert!")}
}

func main() {
    defer output.Flush()
    //solve()
    //return
	var t int64
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
}

func solve() {
    var n int
    fmt.Fscan(input, &n)
    ans := 0
    for i := 0; i < n; i++ {
        var tmp int
        fmt.Fscan(input, &tmp)
        ans = max(ans, tmp - i - 1)
    }
    fmt.Fprintln(output, ans)
}

func abs(x int64) int64 {
    if x >= 0 { return x}
    return -x
}

func max(a, b int) int {
    if a > b { return a}
    return b
}
func min(a, b int) int {
    if a < b { return a}
    return b
}

package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var tc int
	fmt.Fscan(in, &tc)
	for ; tc > 0; tc-- {
		var n, m int
		fmt.Fscan(in, &n)
		for i := 1; i <= n; i++ {
			var a int
			fmt.Fscan(in, &a)
			m++
			if m < a {
				m = a
			}
		}
		fmt.Fprintln(out, m-n)
	}
}

package main

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

func Max(arg ...int) int {
	m := arg[0]
	for _, v := range arg {
		if v > m {
			m = v
		}
	}
	return m
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		n := 0
		fmt.Fscan(f, &n)
		p, mx, k := 0, -1, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &p)
			if p > mx {
				mx, k = p, j
			}
		}
		fmt.Fprintln(w, Max(mx-k-1, 0))
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

func Max(arg ...int) int {
	m := arg[0]
	for _, v := range arg {
		if v > m {
			m = v
		}
	}
	return m
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		n := 0
		fmt.Fscan(f, &n)
		o, mx, k := make([]int, n), -1, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &o[j])
			if o[j] > mx {
				mx, k = o[j], j
			}
		}
		fmt.Fprintln(w, Max(mx-k-1, 0))
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

func Max(arg ...int) int {
	m := arg[0]
	for _, v := range arg {
		if v > m {
			m = v
		}
	}
	return m
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		n := 0
		fmt.Fscan(f, &n)
		o, mx, k := make([]int, n), -1, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &o[j])
			if o[j] >= mx {
				mx, k = o[j], j
			}
		}
		fmt.Fprintln(w, Max(mx-k-1, 0))
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		n := 0
		fmt.Fscan(f, &n)
		o, mx, k := make([]int, n), -1, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &o[j])
			if o[j] >= mx {
				mx, k = o[j], j
			}
		}
		fmt.Fprintln(w, (mx - k - 1))
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

func Max(arg ...int) int {
	m := arg[0]
	for _, v := range arg {
		if v > m {
			m = v
		}
	}
	return m
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		n := 0
		fmt.Fscan(f, &n)
		o, tot, it, p := make([]int, n), 0, 1, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &o[j])
		}
		for j := 0; j < n; j++ {
			if o[j] > p {
				tot += Max(o[j]-p-it, 0)
				p, it = o[j], 1
			} else {
				it++
			}
		}
		fmt.Fprintln(w, tot)
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		n := 0
		fmt.Fscan(f, &n)
		o, tot, it, p := make([]int, n), 0, 1, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &o[j])
		}
		for j := 0; j < n; j++ {
			if o[j] > p {
				tot += (o[j] - p - it)
				p, it = o[j], 1
			} else {
				it++
			}
		}
		fmt.Fprintln(w, tot)
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
	// redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		A()
	}
}

func A() {
	var n int64
	scan(&n)
	var a = make([]int64, n)
	for i := range a {
		scan(&a[i])
	}
	max := func(i, j int64) int64 {
		if i > j {
			return i
		}
		return j
	}
	var ans, idx int64
	for i, v := range a {
		idx = max(idx, int64(i)+1)
		ans += max(0, v-idx)
		idx = max(idx, v+1)
	}
	printf("%v\n", ans)
}

func solve() {
	var n int
	scan(&n)
	var g = make([][]int, n)
	for i := 0; i < n-1; i++ {
		var u, v int
		scan(&u, &v)
		u--
		v--
		g[u] = append(g[u], v)
		g[v] = append(g[v], u)
	}

	var (
		color     = make([]int, n)
		colorSize = [2]int{}
		bicolor   func(u, c int)
	)
	for i := range color {
		color[i] = -1
	}
	bicolor = func(u, c int) {
		if color[u] != -1 {
			return
		}
		color[u] = c
		colorSize[c]++
		for _, v := range g[u] {
			bicolor(v, c^1)
		}
	}
	bicolor(0, 0)

}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
	// redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		A()
	}
}

func A() {
	var n int64
	scan(&n)
	var a = make([]int64, n)
	for i := range a {
		scan(&a[i])
	}
	max := func(i, j int64) int64 {
		if i > j {
			return i
		}
		return j
	}
	var ans, idx int64
	for i, v := range a {
		idx = max(idx, int64(i)+1)
		if v <= idx {
			continue
		}
		ans += v - idx
		idx = v + 1
	}
	printf("%v\n", ans)
}

func solve() {
	var n int
	scan(&n)
	var g = make([][]int, n)
	for i := 0; i < n-1; i++ {
		var u, v int
		scan(&u, &v)
		u--
		v--
		g[u] = append(g[u], v)
		g[v] = append(g[v], u)
	}

	var (
		color     = make([]int, n)
		colorSize = [2]int{}
		bicolor   func(u, c int)
	)
	for i := range color {
		color[i] = -1
	}
	bicolor = func(u, c int) {
		if color[u] != -1 {
			return
		}
		color[u] = c
		colorSize[c]++
		for _, v := range g[u] {
			bicolor(v, c^1)
		}
	}
	bicolor(0, 0)

}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
// 	redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		A()
	}
}

func A() {
	var n int
	scan(&n)
	var a = make([]int, n)
	for i := range a {
		scan(&a[i])
	}
	max := func(i, j int) int {
		if i > j {
			return i
		}
		return j
	}
	ans, j := 0, 1
	for idx, i := range a {
		j = max(j, idx+1)
		ans += max(0, i-j)
		j = max(j, i+1)
	}
	printf("%v\n", ans)
}

func solve() {
	var n int
	scan(&n)
	var g = make([][]int, n)
	for i := 0; i < n-1; i++ {
		var u, v int
		scan(&u, &v)
		u--
		v--
		g[u] = append(g[u], v)
		g[v] = append(g[v], u)
	}

	var (
		color     = make([]int, n)
		colorSize = [2]int{}
		bicolor   func(u, c int)
	)
	for i := range color {
		color[i] = -1
	}
	bicolor = func(u, c int) {
		if color[u] != -1 {
			return
		}
		color[u] = c
		colorSize[c]++
		for _, v := range g[u] {
			bicolor(v, c^1)
		}
	}
	bicolor(0, 0)

}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
// 	redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		A()
	}
}

func A() {
	var n int
	scan(&n)
	var a = make([]int, n)
	for i := range a {
		scan(&a[i])
	}
	max := func(i, j int) int {
		if i > j {
			return i
		}
		return j
	}
	ans, j := 0, 1
	for _, i := range a {
		ans += max(0, i-j)
		j = max(j, i+1)
	}
	printf("%v\n", ans)
}

func solve() {
	var n int
	scan(&n)
	var g = make([][]int, n)
	for i := 0; i < n-1; i++ {
		var u, v int
		scan(&u, &v)
		u--
		v--
		g[u] = append(g[u], v)
		g[v] = append(g[v], u)
	}

	var (
		color     = make([]int, n)
		colorSize = [2]int{}
		bicolor   func(u, c int)
	)
	for i := range color {
		color[i] = -1
	}
	bicolor = func(u, c int) {
		if color[u] != -1 {
			return
		}
		color[u] = c
		colorSize[c]++
		for _, v := range g[u] {
			bicolor(v, c^1)
		}
	}
	bicolor(0, 0)

}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n,max int
		fmt.Fscan(in,&n)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
			if list[j]>max || j==0{
				max=list[j]
			}
		}
		var tally int
		for j:=0;j<n;j++{
			if list[j] > j+1 {
				tally++
			}
		}
		if max > n {
			fmt.Fprintln(out,max-n+tally)
		} else {
			fmt.Fprintln(out,tally)
		}

	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n,max int
		fmt.Fscan(in,&n)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
			if list[j]>max || j==0{
				max=list[j]
			}
		}
		var tally int
		for j:=1;j<n;j++{
			if list[j] < list[j-1] {
				tally++
			}
		}
		if max > n {
			fmt.Fprintln(out,max-n+tally)
		} else {
			fmt.Fprintln(out,tally)
		}

	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n,max int
		fmt.Fscan(in,&n)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
			if list[j]>max || j==0{
				max=list[j]
			}
		}
		var tally int
		for j:=1;j<n;j++{
			if list[j] < list[j-1] {
				tally++
			}
		}
		fmt.Fprintln(out,max-n+tally)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		var shift int
		for i := 0; i < n; i++ {
			var v int
			fmt.Fscan(in, &v)

			if v > i+1 && v-i+1 > shift {
				shift = v - i - 1
			}
		}
		fmt.Fprintln(out, shift)
	}
}

package main

import (
	"fmt"
)

func proc() {
	var n, x, k int
	k = 0
	fmt.Scanf("%d", &n)
	for i := 1; i <= n; i++ {
		k++
		fmt.Scanf("%d", &x)
		if x > k {
			k = x
		}
	}
	fmt.Println(k)
}

func main() {
	var t int
	fmt.Scanf("%d", &t)
	for i := 0; i < t; i++ {
		proc()
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"time"
)

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MINN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func MAXX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

func Union(a, b []int) []int {
	m := make(map[int]bool)

	for _, item := range a {
		m[item] = true
	}

	for _, item := range b {
		if _, ok := m[item]; !ok {
			a = append(a, item)
		}
	}
	return a
}

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

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)
	for o := 0; o < t; o++ {

		var n int
		fmt.Fscan(input, &n)

		B := make([]int, 1)
		for i := 1; i <= n; i++ {
			var q int
			fmt.Fscan(input, &q)
			if q > i {
				B = append(B, q-i)
			}
		}
		q := len(B)
		fmt.Println(B[q-1])
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
var T, N int
var A int

func main() {
	defer out.Flush()

	fmt.Fscan(in, &T)
	var ans int
	for ; T > 0; T-- {
		fmt.Fscan(in, &N)
		for i := 0; i < N; i++ {
			fmt.Fscan(in, &A)
			if v := A - i - 1; v > ans {
				ans = v
			}
		}
		fmt.Fprintln(out, ans)
	}
}

package main

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

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		readInt(reader)
		a := readArrayInt64(reader)

		var sum int64 = 0
		for i, v := range a {
			if v > int64(i) {
				sum += v - (int64(i+1)+sum)
			}
		}

		fmt.Fprintln(writer, sum)

		t--
	}

	writer.Flush()
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}


// 83A
package main

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

func main() {
	var i, k, n, s, x, y int64
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n)
	fmt.Fscan(in, &x)
	s = n
	for i = 2; i <= n; i++ {
		fmt.Fscan(in, &y)
		if x == y {
			k++
			s += k
		} else {
			k = 0
		}
		x = y
	}
	fmt.Print(s)
}

//83A
package main
import (
	"fmt"
	"os"
	"bufio"
	"strconv"
)

func main() {
	var nn, x int
	var aa, t, y int64
	x=0
	y=2
	t=0
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	r.Scan()
	nn, _ = strconv.Atoi(r.Text())

	for i:=1; i<=nn; i++ {
		r.Scan()
		aa, _ = strconv.ParseInt(r.Text(), 0, 64)
		if aa==y {
			x+=1
		} else {
			x=1
			y=aa
		}
		t+=int64(x)
	}
	fmt.Println(t)
}

// 83A
package main

import (
	"fmt"
)

func main() {
	var i, k, n, s, x, y int64
	fmt.Scan(&s)
	fmt.Scan(&x)
	s = n
	for i = 2; i <= n; i++ {
		fmt.Scan(&y)
		if x == y {
			k++
			s += k
		} else {
			k = 0
		}
		x = y
	}
	fmt.Print(s)
}