using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_169
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            long[] array = ReadLongs();
            for(int i = 0; i < n; i++)
            {
                if (array[i] == 0)
                {
                    WriteLine(0);
                    return;
                }
            }

            int[] val = new int[60];
            val[0] = 1;
            for (int i = 0; i < n; i++)
            {
                int[] next = new int[60];
                long remain = array[i];
                int div = 0;
                while (remain > 0)
                {
                    int dig = (int)(remain % 10);
                    for (int j = 0; j + div < 60; j++)
                    {
                        next[j + div] += val[j] * dig;
                    }
                    div++;
                    remain /= 10;
                }

                for (int j = 0; j < 60 - 1; j++)
                {
                    next[j + 1] += next[j] / 10;
                    next[j] %= 10;
                }

                for (int j = 19; j < 60; j++)
                {
                    if (next[j] > 0)
                    {
                        WriteLine(-1);
                        return;
                    }
                }

                if (next[18] > 1)
                {
                    WriteLine(-1);
                    return;
                }

                if (next[18] == 1)
                {
                    for (int j = 0; j < 18; j++)
                    {
                        if (next[j] > 0)
                        {
                            WriteLine(-1);
                            return;
                        }
                    }
                }

                val = next;
            }

            bool isMax = true;
            for (int i = 60 - 1; i >= 0; i--)
            {
                if (isMax)
                {
                    if (val[i] > 0)
                    {
                        Write(val[i]);
                        isMax = false;
                    }
                }
                else
                {
                    Write(val[i]);
                }
            }
            WriteLine();
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static decimal[] ReadDecimals() { return Array.ConvertAll(Read().Split(), decimal.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 46924