Harmonic Average

Interview

Time limit2sMemory limit128 MB

Summary
Compute the harmonic average of up to 9 natural numbers as a reduced fraction, printing the shortest, lexicographically smallest equivalent representation.
Level

Medium4 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

For N natural numbers A[1], ..., A[N], this problem defines the harmonic average as the following value.

1 / (1/A\[1] + 1/A\[2] + ... + 1/A\[N])

In other words, take the reciprocal of each number, add those reciprocals, and then take the reciprocal of that sum. For 1, 2, and 4, the value is 4/7.

Given N natural numbers A[1], ..., A[N], write a program that prints the harmonic average according to this definition.

Input

The first line contains a natural number N (1 <= N <= 9).

The second line contains A[1], ..., A[N] in order. Each A[i] is a natural number not greater than 100.

Output

Print the answer as a fraction on the first line.

If the same value can be represented in multiple ways, print the representation that uses the fewest total characters among digits and /. If there is more than one such representation, print the lexicographically smallest one.

Hint

The usual harmonic mean is N / (1/A\[1] + 1/A\[2] + ... + 1/A\[N]), but in this problem, the value defined in the statement is called the harmonic average.

Examples1

  1. Example 1

    Input
    3
    4 1 2
    
    Expected output
    4/7