#include <bits/stdc++.h>
using namespace std;
#define all(v) (v.begin(),v.end())
#define sz(v) ((int)((v).size()))
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define endl '\n'

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair< ll, ll> pll;
typedef vector<pll> vll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ull> vul;
typedef vector<pii> vii;
typedef vector<vi> vvi;

void fast() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("inputf.txt", "r", stdin);
	freopen("outputf.txt", "w", stdout);
#endif
}
void solve()
{

}
bool have_7(int num)
{
	while (num)
	{
		int d = num % 10;
		num /= 10;
		if (d == 7) return true;
	}
	return false;
}
int decimaltooctal(int decimalNum)
{
	int octalNum = 0, placeValue = 1;
	int dNo = decimalNum;
	while (decimalNum != 0) {
		octalNum += (decimalNum % 8) * placeValue;
		decimalNum /= 8;
		placeValue *= 10;
	}
	return octalNum;
}
int to_int(string s)
{
	stringstream k(s);
	int x = 0;
	k >> x;
	return x;
}
int main() {
	fast();
	int n;
	cin >> n;
	int res = n;
	for (int i = 1; i <= n; i++)
	{
		if (have_7(decimaltooctal(i)) || have_7(i))
			res--;
	}
	cout << res << endl;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    int m = n / 2;
    ll a[n], b[n];
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) {
        cin >> b[i];
    }
    ll ans = 0;
    vector<ll> even, odd;
    rep(i, n) {
        ll c = a[i] - b[i];
        if (i % 2 == 0) {
            even.emplace_back(c);
        } else {
            odd.emplace_back(c);
        }
        ans += max(a[i], b[i]);
    }
    sort(ALL(even));
    sort(ALL(odd));
    rep(i, m) {
        if (even[i] * odd[i] < 0) {
            ans -= min(abs(even[i]), abs(odd[i]));
        }
    }
    cout << ans << endl;
    return 0;
}