Under construction

Still being built. Things may change

Dorayaki

Interview

Time limit2sMemory limit2048 MB

Summary
Given tastiness values for N fillings and M skins, sum (a+b) times max(a,b) over every filling and skin pair.
Level

Easy2 of 10

Topics
Brute force, Implementation
Solved
No attempts yet

Problem

JOI is making dorayaki.

Each dorayaki is made from exactly one filling and one skin. Every filling and skin has a tastiness value, which is a positive integer. There are N kinds of fillings numbered 1 to N, and the tastiness of filling i is Ai. There are M kinds of skins numbered 1 to M, and the tastiness of skin j is Bj.

JOI tries every combination of filling and skin, making N × M dorayaki. The tastiness of each dorayaki is the sum of its filling and skin tastiness, multiplied by the larger of those two values.

Find the total tastiness of all N × M dorayaki.

Input

The input is given in the following format.

N M
A1 A2 … AN
B1 B2 … BM

Output

Print the total tastiness of all N × M dorayaki.

Print only the answer. Do not print any prompt or other text.

Constraints

  • 1 ≦ N ≦ 100.
  • 1 ≦ M ≦ 100.
  • 1 ≦ Ai ≦ 100 (1 ≦ i ≦ N).
  • 1 ≦ Bj ≦ 100 (1 ≦ j ≦ M).
  • All input values are integers.

Examples3

  1. Example 1

    Input
    2 2
    1 2
    2 5
    
    Expected output
    79
    
  2. Example 2

    Input
    1 5
    50
    9 7 5 4 1
    
    Expected output
    13800
    
  3. Example 3

    Input
    15 5
    5 10 52 31 14 16 19 1 9 20 80 19 11 34 72
    20 2 4 9 19
    
    Expected output
    116756