#include <iostream>
#include <cassert>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>

using namespace std;

double m[1000][1000];
double p[1000];
double psum[1000];
double inf = 100000000000000000000.0;

#define file cin

int solve( int a, int b ) {
	if( a == b )
		return 0;
	if( m[a][b] < inf ) return m[a][b];
	for( int c = a+1; c < b; c+=2 ) {
		m[a][b] = min(solve( a, c-1 ) + solve( c+1, b ) + psum[b+1] - psum[a], m[a][b]);
	}
	return m[a][b];
}

int main() {
	//ifstream file( "greed.in" )
	int n;
	while( cin >> n ) {
		if( n == 0 ) break;
		for( int i = 0; i < n; i++ )
			file >> p[i*2+1];
		for( int i = 0; i < n+1; i++ )
			file >> p[i*2];

		n = 2*n+1;
		psum[0] = 0;
		for( int i = 1; i <= n; i++ )
			psum[i] = psum[i-1] + p[i-1];
		for( int i = 0;i < n; i++ )
			for( int j = 0; j < n; j++ )
				m[i][j] = inf;
		cout << solve( 0, n-1 ) << endl;
	}

	return 0;
}
