#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    int arr[n];
    int arr2[n];
    
    for(int i =0; i < n; i++)
    {
        cin >> arr[i];
    }
    for(int i =0; i < n; i++)
    {
        cin >> arr2[i];
    }
    if(n == 1)
    {
        cout << arr2[0];
        return 0;
    }
    sort(arr2, arr2+n);
    cout << arr2[0] + arr2[n-1];
}
