PEG 11/12 Programming Test 1 - October 19

Problem 1: Cyclopian Air

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

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

Output

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

Sample Input

10
2
5
6
12
76
0
200
1
32
14

Sample Output

912

All Submissions
Best Solutions


Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 17, 2011
Author: jargon

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

It's quiet in here...