eolymp
bolt
Try our new interface for solving problems
Məsələlər

Game "15++"

Game "15++"

The game "15++" has now become popular in various TV shows. Participants are given the same sets of N cards, each of which has one of the numbers "5" or "7" written on it. The winner is the one who of these cards will lay out the maximum number that is divisible by 15. For example, if the participants receive 3 cards each {“7”, “5”, “7”}, then those who laid out the number 75 are declared the winners.

Input

The program enters one natural number from the keyboard: N (from 2 to 1000) - the number of cards, and then in the next line N digits 5 or 7.

Output

Write in a single line the maximum number without gaps (not all cards can be used). If such a number cannot be obtained from this set, print the message "Impossible" (without quotes).

Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB
Giriş verilənləri #1
3
7 5 7
Çıxış verilənləri #1
75
Mənbə Dnipro Open School Olympiad in Informatics 2020