#include <bits/stdc++.h>
using namespace std;
const int MAXN = 400;
int c[MAXN];
int n;
int temp[MAXN];
int g[MAXN];
void CalcGreedy(int num, int arr[]) {
  memset(arr, 0, sizeof arr);
  for (int i = 0; i < n; ++i) {
    arr[i] = num / c[i];
    num -= arr[i] * c[i];
  }
}
int CalcNum(int arr[]) {
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    ret += arr[i] * c[i];
  }
  return ret;
}
bool IsLess(int a1[], int a2[]) {
  int a = 0, b = 0;
  for (int i = 0; i < n; ++i) {
    a += a1[i];
    b += a2[i];
  }
  return a < b;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
  }
  int ret = -1;
  for (int i = 1; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      CalcGreedy(c[i - 1] - 1, temp);
      ++temp[j];
      for (int k = j + 1; k < n; ++k) temp[k] = 0;
      int w = CalcNum(temp);
      CalcGreedy(w, g);
      bool less = IsLess(temp, g);
      if (less) {
        if (ret == -1 || w < ret) ret = w;
      }
    }
  }
  cout << ret << endl;
  return 0;
}
