using System;
using System.IO;
using System.Linq;
using System.Runtime.Remoting.Contexts;

namespace Contest
{
    class Program
    {
        private Scanner sc;
        private int N, K;
        private long[] A;
        public void Solve()
        {
            sc = new Scanner();
            N = sc.NextInt();
            K = sc.NextInt();
            A = sc.LongArray();

            // 操作してもAの合計は変わらない
            // 答えはΣAの約数

            long sum = 0;
            foreach (var i in A)
            {
                sum += i;
            }

            long ans = 1;
            for (long i = 1; i * i <= sum; i++)
            {
                if (sum % i == 0)
                {
                    if (Query(i) <= K)
                    {
                        ans = Math.Max(ans, i);
                    }

                    if (Query(sum / i) <= K)
                    {
                        ans = Math.Max(ans, sum / i);
                    }
                }
            }

            Console.WriteLine(ans);
        }

        /// <summary>
        /// GCDがnになる最小の操作回数
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        private long Query(long n)
        {
            var tmpA = A.ToArray();
            for (int i = 0; i < N; i++)
            {
                tmpA[i] %= n;
            }
            Array.Sort(tmpA);

            long sum = 0;
            foreach (var l in tmpA)
            {
                sum += l;
            }

            long res = long.MaxValue;
            // マイナスに操作する回数
            long left = 0;
            for (int i = 0; i <= N; i++)
            {
                // プラスに操作する回数
                // Σ(n-tmpA[k])
                long right = n * (N - i) - (sum - left);
                res = Math.Min(res, Math.Max(left, right)+Math.Abs(left-right));

                if (i < N)
                {
                    left += tmpA[i];
                }
            }

            return res;
        }


        static void Main() => new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
        _separator = ' ';
    }
    private readonly char _separator;
    private readonly StreamReader _stream;
    private int _pos;
    private string[] _line;
    #region get a element
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(_separator);
            _pos = 0;
        }
        return _line[_pos++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    #endregion
    #region convert array
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }
    #endregion
    #region get array
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(_separator);
        _pos = _line.Length;
        return _line;
    }
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
    #endregion
}

Measured memory_bytes: 17464