package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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 minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

func listDivisor(n int) []int {
	var ret []int
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			ret = append(ret, i)
			ret = append(ret, n/i)
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(ret)))
	return ret
}

func main() {
	n, k := readInt(), readInt()

	sum := 0
	a := make([]int, n)
	for i := range a {
		a[i] = readInt()
		sum += a[i]
	}

	divisors := listDivisor(sum)
	// fmt.Println(divisors)

	for i := range divisors {
		b := make([]int, n)
		for j := range a {
			b[j] = a[j] % divisors[i]
		}
		sort.Ints(b)
		// fmt.Println("b:", b)

		r, l := 0, n-1
		plus, minus := 0, 0
		for r <= l {
			if max(plus, minus) > k {
				plus, minus = 0, 1
				break
			}
			if plus < minus {
				// fmt.Printf("+%v", divisors[i]-b[l])
				plus += divisors[i] - b[l]
				l--
			} else {
				// fmt.Printf("-%v", b[r])
				minus += b[r]
				r++
			}
		}
		// fmt.Println()
		// fmt.Printf("divisors: %v, plus: %v, minus: %v\n", divisors[i], plus, minus)

		if plus == minus && plus <= k {
			fmt.Println(divisors[i])
			return
		}
	}
}


Measured memory_bytes: 5376