#import <Foundation/Foundation.h>

@interface Road : NSObject
@property (nonatomic,assign)NSInteger dir;
@property (nonatomic,assign)NSInteger len;
@end

@implementation Road
@end

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSData *stdinData = [[NSFileHandle fileHandleWithStandardInput] availableData];
        NSString *stdinString = [[NSString alloc] initWithData:stdinData encoding:NSUTF8StringEncoding];
        NSArray *stdinArray = [stdinString componentsSeparatedByString:@" "];
        NSInteger w = [[stdinArray objectAtIndex:0] intValue];
        NSInteger h = [[stdinArray objectAtIndex:1] intValue];
        NSMutableArray *pq = [NSMutableArray array];
        
        for (int i=0;i<w+h;i++){
            NSData *stdinData = [[NSFileHandle fileHandleWithStandardInput] availableData];
            NSString *stdinString = [[NSString alloc] initWithData:stdinData encoding:NSUTF8StringEncoding];
            Road *road = [[Road alloc] init];
            road.len = [stdinString intValue];
            if (i<w) {
                road.dir = 0;
            }
            else{
                road.dir = 1;
            }
            [pq addObject:road];
        }

        NSSortDescriptor *sort1 = [NSSortDescriptor sortDescriptorWithKey:@"length" ascending:YES];
        pq = (NSMutableArray*)[pq sortedArrayUsingDescriptors:@[sort1]];
        w++;h++;
        
        NSInteger ans = 0;
        for (Road* obj in pq) {
            if (obj.dir) {
                ans += obj.len * w;
                h--;
            }
            else {
                ans += obj.len * h;
                w--;
            }
        }
        
        NSString *output_str = [NSString stringWithFormat:@"%d",ans];
        NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];
        [fileHandle writeData:[output_str dataUsingEncoding:NSUTF8StringEncoding]];
        [fileHandle writeData:[@"\n" dataUsingEncoding:NSUTF8StringEncoding]];
        [fileHandle closeFile];
    }
    return 0;
}
