Files
pythonmc/levieProekti/Olymp2020/gorodolymp2tour14,12,2020/15++.py
BarsTiger 68fb5410ee 1
2021-10-15 12:46:53 +03:00

26 lines
584 B
Python

import copy
import itertools
max = 0
ostatki = []
n = int(input())
chisla = map(int, input().split())
oldallresults = []
somechisl = ""
for i in range(1, n + 1):
newlist = copy.deepcopy(chisla)
result = itertools.combinations(newlist, i)
oldallresults.extend(result)
for i in range(len(oldallresults)):
for j in oldallresults[i]:
somechisl = str(somechisl) + str(j)
intsomechisl = int(somechisl)
if intsomechisl % 15 == 0 and intsomechisl > max:
max = intsomechisl
somechisl = ""
if max != 0:
print(max)
else:
print("Impossible")