#include <bits/stdc++.h>
using namespace std;
vector<int> greedy_change(const vector<int>& c, int x) {
  int n = int(c.size());
  vector<int> g(n);
  for (int i = 0; i < n; ++i) {
    g[i] = x / c[i];
    x -= g[i] * c[i];
  }
  return g;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> c(n);
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
  }
  int ans = -1;
  for (int i = 1; i < n; ++i) {
    vector<int> gi = greedy_change(c, c[i - 1] - 1);
    for (int j = i; j < n; ++j) {
      int w = 0;
      int m_siz = 0;
      for (int k = 0; k < j; ++k) {
        w += gi[k] * c[k];
        m_siz += gi[k];
      }
      w += (gi[j] + 1) * c[j];
      m_siz += gi[j] + 1;
      vector<int> g = greedy_change(c, w);
      int g_siz = 0;
      for (int i = 0; i < n; ++i) {
        g_siz += g[i];
      }
      if (m_siz < g_siz && (ans == -1 || w < ans)) {
        ans = w;
      }
    }
  }
  cout << ans << endl;
}
