#include <bits/stdc++.h>
using namespace std;
int dp[3010][3010][4];
int a[3010], c[3010];
int n;
int solve(int i, int last, int cnt) {
  if (cnt < 0) return 500000000;
  if (i == n) {
    if (cnt == 0)
      return 0;
    else
      return 500000000;
  }
  if (dp[i][last][cnt] != -1) return dp[i][last][cnt];
  int ret = 500000000;
  if (last == i) {
    ret = min(ret, solve(i + 1, i, cnt - 1) + c[i]);
  }
  if (last < i and a[i] > a[last])
    ret = min(ret, solve(i + 1, i, cnt - 1) + c[i]);
  if (last == i)
    ret = min(solve(i + 1, i + 1, cnt), ret);
  else
    ret = min(solve(i + 1, last, cnt), ret);
  return dp[i][last][cnt] = ret;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> c[i];
  memset(dp, -1, sizeof(dp));
  int ans = solve(0, 0, 3);
  sort(c, c + n);
  long long max_pos = c[n - 1] + c[n - 2] + c[n - 3];
  assert(max_pos < 3 * 500000000);
  cerr << 3 * 500000000 << endl;
  if (ans > max_pos)
    cout << "-1\n";
  else
    cout << ans << endl;
  return 0;
}
