import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int k = sc.nextInt(); long[] values = new long[n]; HashSet type = new HashSet<>(); for (int i = 0; i < n; i++) { values[i] = sc.nextLong(); for (long j = 1; j <= Math.sqrt(values[i]); j++) { if (values[i] % j == 0) { type.add(j); type.add(values[i] / j); } } } long ans = 1; for (long x : type) { if (getCount(values, x) <= k) { ans = Math.max(ans, x); } } System.out.println(ans); } static long getCount(long[] values, long x) { long[] mod = new long[values.length]; long[] minus = new long[values.length]; for (int i = 0; i < values.length; i++) { mod[i] = values[i] % x; } Arrays.sort(mod); for (int i = 0; i < values.length; i++) { if (mod[i] > 0) { minus[i] = x - mod[i]; } if (i > 0) { mod[i] += mod[i - 1]; } } for (int i = values.length - 2; i >= 0; i--) { minus[i] += minus[i + 1]; } long ans = Math.min(minus[0], mod[values.length - 1]); for (int i = 0; i < values.length - 1; i++) { ans = Math.min(ans, mod[i] + minus[i + 1]); } return ans; } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }