import sys


def solve(N, E, C):
    S = 0
    m = C[0]
    for i in range(0, len(E)):
        if C[i] <= m:
            m = C[i]
        S += m * E[i]
    return S


if __name__ == '__main__':
    print(solve(int(sys.stdin.readline()), list(map(int, sys.stdin.readline
        ().split())), list(map(int, sys.stdin.readline().split()))))

c87452f4ccdc8d150c61bc4ac0b32816173b43e7
<mask token>

<mask token>


def solve(N, E, C):
    S = 0
    m = C[0]
    for i in range(0, len(E)):
        if C[i] <= m:
            m = C[i]
        S += m * E[i]
    return S


<mask token>

<mask token>


def solve(N, E, C):
    S = 0
    m = C[0]
    for i in range(0, len(E)):
        if C[i] <= m:
            m = C[i]
        S += m * E[i]
    return S


if __name__ == '__main__':
    print(solve(int(sys.stdin.readline()), list(map(int, sys.stdin.readline
        ().split())), list(map(int, sys.stdin.readline().split()))))

import sys


def solve(N, E, C):
    S = 0
    m = C[0]
    for i in range(0, len(E)):
        if C[i] <= m:
            m = C[i]
        S += m * E[i]
    return S


if __name__ == '__main__':
    print(solve(int(sys.stdin.readline()), list(map(int, sys.stdin.readline
        ().split())), list(map(int, sys.stdin.readline().split()))))
