#include <bits/stdc++.h>
using namespace std;
const int maxn = 400;
int n;
int a[maxn + 1];
int greedy(int *a, int s, int *res) {
  int sum = 0;
  for (int i = 0; i < n && s > 0; i++) {
    if (a[i] <= s) {
      res[i] = s / a[i];
      sum += res[i];
      s %= a[i];
    }
  }
  return sum;
}
int main(int argc, char **argv) {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int res = -1;
  for (int i = n - 2; i >= 0 && res < 0; i--) {
    int b[maxn] = {0}, c[maxn];
    greedy(a, a[i] - 1, b);
    int k = 0, j;
    for (j = 0; j < n && b[j] == 0; j++)
      ;
    int sum = 0, num = 0;
    for (; j < n; j++) {
      sum += a[j] * (b[j] + 1);
      num += b[j] + 1;
      if (greedy(a, sum, c) > num) {
        res = sum;
      }
      sum -= a[j];
      num--;
    }
  }
  printf("%d", res);
  fclose(stdin);
  fclose(stdout);
  return 0;
}
