package main
import (
"bufio"
"fmt"
"math/bits"
"os"
"sort"
)
type Point struct {
x, y int64
}
type Int128 struct {
hi int64
lo uint64
}
func mul(a, b int64) Int128 {
hi, lo := bits.Mul64(uint64(a), uint64(b))
var h = int64(hi)
if a < 0 {
h -= b
}
if b < 0 {
h -= a
}
return Int128{h, lo}
}
func add(a, b Int128) Int128 {
lo, carry := bits.Add64(a.lo, b.lo, 0)
hi, _ := bits.Add64(uint64(a.hi), uint64(b.hi), carry)
return Int128{int64(hi), lo}
}
func negate(a Int128) Int128 {
lo, borrow := bits.Sub64(0, a.lo, 0)
hi, _ := bits.Sub64(0, uint64(a.hi), borrow)
return Int128{int64(hi), lo}
}
func dotProduct(v, u Point) Int128 {
p1 := mul(v.x, u.x)
p2 := mul(v.y, u.y)
return add(p1, p2)
}
func gcd(a, b int64) int64 {
for b != 0 {
a, b = b, a%b
}
return a
}
func abs(a int64) int64 {
if a < 0 {
return -a
}
return a
}
func main() {
reader := bufio.NewReader(os.Stdin)
var n int
if _, err := fmt.Fscan(reader, &n); err != nil {
return
}
pts := make([]Point, n)
var sumX, sumY int64
for i := 0; i < n; i++ {
fmt.Fscan(reader, &pts[i].x, &pts[i].y)
sumX += pts[i].x
sumY += pts[i].y
}
V := make([]Point, n)
for i := 0; i < n; i++ {
V[i].x = int64(n)*pts[i].x - sumX
V[i].y = int64(n)*pts[i].y - sumY
}
freq := make(map[Point]int)
for _, v := range V {
freq[v]++
}
var R []Point
for v, count := range freq {
negV := Point{-v.x, -v.y}
negCount := freq[negV]
if count > negCount {
for i := 0; i < count-negCount; i++ {
R = append(R, v)
}
}
}
if len(R) == 0 {
fmt.Println("-1")
return
}
v1 := R[0]
candidates := make(map[Point]bool)
for _, vj := range R {
w := Point{v1.x + vj.x, v1.y + vj.y}
if w.x == 0 && w.y == 0 {
continue
}
g := gcd(abs(w.x), abs(w.y))
w.x /= g
w.y /= g
if w.x < 0 || (w.x == 0 && w.y < 0) {
w.x = -w.x
w.y = -w.y
}
candidates[w] = true
}
ans := 0
dots := make([]Int128, len(R))
for w := range candidates {
u := Point{-w.y, w.x}
for i, v := range R {
dots[i] = dotProduct(v, u)
}
sort.Slice(dots, func(i, j int) bool {
if dots[i].hi != dots[j].hi {
return dots[i].hi < dots[j].hi
}
return dots[i].lo < dots[j].lo
})
valid := true
for i := 0; i < len(dots); i++ {
if dots[i] != negate(dots[len(dots)-1-i]) {
valid = false
break
}
}
if valid {
ans++
}
}
fmt.Println(ans)
}