Doubled GCD
시간 제한2초메모리 제한1024 MB
카드 두 장 x, y를 2*gcd(x, y)로 바꾸는 연산을 N-1번 해 마지막 카드에 적힌 수를 최대로 만든다.
문제
There are cards in a deck, numbered from to , where card has a positive integer written on it.
You are to perform moves with the cards. In each move, you select two cards of your choice from the deck. Let and be the integers written on the selected cards, respectively. Remove both selected cards, and insert a new card into the deck with written on it, where is the greatest common divisor of and . Note that with this one move, there will be one fewer card in the deck (as you remove two cards and insert one new card).
After all moves have been performed, there will be exactly one card remaining. Your goal is to maximize the integer written on the last card; output this integer.
입력
Input begins with an integer () representing the number of cards. The next line contains integers () representing the number written on card .
출력
Output an integer in a single line representing the maximum possible integer written on the last card.