using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using static System.Math; using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute; using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions; public static class P { public static void Main() { int n = int.Parse(Console.ReadLine()); var a = Console.ReadLine().Split().Select(long.Parse).ToArray(); long gcd = a.Where(x => x != -1).Aggregate(0L, GCD); if (gcd == 0) Console.WriteLine(-1); else Console.WriteLine(gcd * gcd); } static long GCD(long a, long b) { while (true) { if (b == 0) return a; a %= b; if (a == 0) return b; b %= a; } } }