#include <bits/stdc++.h>
const int INF = ~0u >> 2;
int main() {
  int n;
  scanf("%d", &n);
  std::vector<int> c(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &c[i]);
  }
  int ans = INF;
  for (int i = 1; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      int x = c[i - 1] - 1;
      int y = 0;
      for (int k = i; k <= j; ++k) {
        int tmp = x / c[k];
        x -= tmp * c[k];
        y += tmp;
      }
      x = c[i - 1] - 1 - x + c[j];
      ++y;
      int w = x;
      if (x < ans) {
        for (int k = 0; k < n; ++k) {
          int tmp = x / c[k];
          x -= tmp * c[k];
          y -= tmp;
        }
        if (y < 0) ans = w;
      }
    }
  }
  if (ans == INF)
    puts("-1");
  else
    printf("%d\n", ans);
  return 0;
}
