Cyclopian Air

View as PDF

Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 16M

Problem type
PEG 11/12 Programming Test 1 - October 19

The upscale clothing company FurWear has recently expanded to the planet of Cyclopia. Cyclopia, however, does not have an atmosphere with oxygen, something that the workers producing FurWear products require to work. (They need food and water too, but they can figure that out on their own!) The Oelfinn, as the dominant species of Cyclopia, have a ready supply of oxygen, but they aren't willing to give it away freely. They do have a love of puzzles, however.

The Oelfinn have placed some numbers on some cards arranged in a circle, and will allow FurWear to pick one pair of adjacent cards. The Oelfinn are willing to give FurWear an amount of oxygen proportional to the product of the numbers on said cards.

Obviously, FurWear would like to maximise the amount of oxygen they receive, and have turned to you to help. Your task is to write a program that will find the largest product of any two adjacent numbers, which will then be stored on a chip implanted into a peon.

Input Specification

The first line consists of a single integer N (8 \le N \le 10\,000). The following N lines each contain a single integer a_{i} (0 \le
a_{i} \le 30\,000), the number on the ith card. The numbers will be given from the northernmost card, then clockwise all the way around.

Output Specification

On a single line, output the maximum product of any two adjacent numbers.

Sample Input


Sample Output



There are no comments at the moment.