using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            long n, k;
            ReadLong(out n, out k);
            int[] A = ReadIntArray();
            int ans = Solve(A, k);
            Console.WriteLine(ans);
        }

        private static int Solve(int[] A, long k)
        {
            int[] divisors = EnumerateDivisors(A.Sum()).OrderByDescending(x => x).ToArray();

            foreach (var d in divisors)
            {
                int[] R = A.Select(a => a % d).OrderBy(x => x).ToArray();
                int[] add = new int[A.Length + 1];
                int[] sub = new int[A.Length + 1];

                for (int i = 0; i < A.Length; i++)
                {
                    int ri = A.Length - i - 1;
                    add[i + 1] = add[i] + R[i];
                    sub[ri] = sub[ri + 1] + (d - R[ri]);
                }

                //Console.WriteLine($"sub: {string.Join(", ", sub)}");
                //Console.WriteLine($"add: {string.Join(", ", add)}");

                for (int i = 0; i < A.Length; i++)
                {
                    //Console.WriteLine($"d = {d}, {sub[i]} {add[i]}");
                    if (sub[i] == add[i] && sub[i] <= k)
                    {
                        return d;
                    }
                }
            }

            return 1;
        }

        static IEnumerable<int> EnumerateDivisors(int n)
        {
            for (int i = 1; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    yield return i;
                    if (n / i != i)
                    {
                        yield return n / i;
                    }
                }
            }
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

Measured memory_bytes: 17552