#K53482. Geometric Progression Checker

    ID: 29541 Type: Default 1000ms 256MiB

Geometric Progression Checker

Geometric Progression Checker

You are given a list of integers. Your task is to determine whether the list forms a geometric progression after sorting the numbers in non-decreasing order. In a geometric progression (GP), every term after the first is obtained by multiplying the previous term by a constant $r$ (i.e., for all valid indices, $a_{i} = a_{i-1} \times r$).

Note:

  • If the list contains only one element, it is considered a geometric progression.
  • If the smallest number is 0, then for the list to be a GP, every number must be 0.
  • Input sequence may be unsorted. Prior to checking the GP property, you must sort the sequence in ascending order.

Your program should read from standard input and write to standard output.

inputFormat

The first line contains an integer $n$, the number of elements in the list. The second line contains $n$ space-separated integers.

outputFormat

Output a single integer: $1$ if the sorted list forms a geometric progression; otherwise, output $0$.

## sample
5
2 4 8 16 32
1