n, m = list(map(int, input().split(" ")))

X = list(map(int, input().split(" ")))
Y = list(map(int, input().split(" ")))

X_diff = []
Y_diff = []

for i in range(len(X)-1):
    X_diff.append((X[i+1]-X[i]))
                  
for i in range(len(Y)-1):
    Y_diff.append((Y[i+1]-Y[i]))
    
    
def diff(l, n):
    a = 0
    for i in range(len(l) - n + 1):
        a += sum(l[i:i+n])
    return a

    
ans = 0
for i in range(n):
    for j in range(m):
        ans += diff(X_diff, i) * diff(Y_diff, j)
        
print(ans)