-- Try yukicoder -- author: Leonardone @ NEETSDKASU import Data.List (find) import qualified Data.Set as S main = interact $ show . solve . map read . tail . words solve xs = maybe 1 (div a) $ find f ys where a = sum xs ys = scanl1 (+) xs s = S.fromList ys f e = m == 0 && (all (flip S.member s) $ map (* e) [1..d]) where (d, m) = divMod a e