import numpy as np N = int(input()) A = list(map(int, input().split())) F = np.fft.fft(A) # 振幅スペクトルを計算 amplitude = np.abs(F) F_amplitude = amplitude / N * 2 F_amplitude[0] = F_amplitude[0] / 2 v = 0 hz = 0 for i in range(len(F_amplitude)): if vmin(hz/HZ[i]-int(hz/HZ[i]),abs(1-hz/HZ[i]+int(hz/HZ[i])))*HZ[i]/HZ[0]: v = min(hz/HZ[i]-int(hz/HZ[i]),abs(1-hz/HZ[i]+int(hz/HZ[i])))*HZ[i]/HZ[0] ans=i print(L[ans])