main :-	read_num(N),
        read_n_num_list(N, L),
        cal(L, 1, M),
        write_ans(M).

write_ans(N) :-
        N > 1000000000000000000, !,
        write(-1), nl.
write_ans(N) :-
        write(N), nl.

cal([], Acc, Acc).
cal([H|T], Old, R) :-
        NewAcc is H * Old,
        cal(T, NewAcc, R).


read_n_num_list(Num, List) :-
	read_n_num_list_aux(Num, [], List),
	!.
read_n_num_list_aux(0, List, List).
read_n_num_list_aux(Num, Old, Accum) :-
	read_num(NewItem),
	NewNum is Num - 1,
	append(Old, [NewItem], NewList),
	read_n_num_list_aux(NewNum, NewList, Accum).

read_str(S) :-
        read_string(current_input, ' \n', '', _, S).

read_num(N) :-
        read_str(S),
        number_string(N, S).

:- main.
