6
12 8 12 17 20 5
17 4 8 8 8 4
 6
4 1 12 9 3 11
12 20 19 12 19 11
 1
1
1
 2
1 2
1 1
 1
7
5
 6
16 20 18 7 14 2
17 12 4 10 7 4

705
 917
 1
 9
 5
 741

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
// package edu48div2c;

import java.io.*;
import java.util.*;

/**
 *
 * @author Mostafa
 */
public class Edu48div2C {

    /**
     * @param args the command line arguments
     */
     public static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
 public static PrintWriter out;
    
    public static int ser ( int x[] , int start , int end , int val )
    {
        while ( start <= end )
	{
            int mid = ( start + end ) / 2 ;
            if ( x[ mid ] <= val )
                start = mid + 1 ;
            else
                end = mid - 1 ;
	}
        return end ;//if you want the upper else return -1 that not exciet
    }
    
 public static  boolean isPrime( long n)
{
    // Corner cases
    if (n < 2)  return false;
    if (n < 4)  return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;

    for (long i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}
    
    public static int search( int x[] , int val )
    {
        return ser( x , 0 , x.length - 1 , val );
    }
    
    
//    public static long re ( long x[] , long y[] , long c , int ix , int iy )
//    {
//        
//    }
    
    
    public static void main(String[] args) {
        // TODO code application logic here
        FastReader in = new FastReader();
        StringBuilder r = new StringBuilder();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);
        int n = in.nextInt() ;
        long y[] = new long[n] ;
        long x[] = new long[n] ;
        for ( int i = 0 ; i < n ; ++i )
            x[i] = in.nextLong() ;
        for ( int i = 0 ; i < n ; ++i )
            y[i] = in.nextLong() ;
        if ( y[0] > y[n-1] && y[0] > x[1] )
        {
            long o = 0 , c = 1 ;
            for ( int i = 1 ; i < n ; ++i )
                o += c++ * x[i] ;
            for ( int i = n - 1 ; i > -1 ; --i )
                o += c++ * y[i] ;
            out.println(o);
        }
        else if ( y[n-1] > y[0] && y[n-1] > x[1] )
        {
            long c = 0 , o = 0 ;
            for ( int i = 0 ; i < n ; ++i )
            {
                o += c++ * x[i] ;
                o += c++ * y[i] ;
            }
            out.println(o);
        }
        else if ( x[1] > y[0] && x[1] > y[n-1] )
        {
            long c = 1 , o = 0 ;
            for ( int i = 0 ; i < n ; ++i )
                o += c++ * y[i] ;
            for ( int i = n - 1 ; i > 0 ; --i )
                o += c++ * y[i] ;
            out.println(o);
        }
    }
    
}
