h ,w = map(int,input().split())
a = [list(map(int, input().split())) for i in range(h)]
minlist = []
suma = []
for i in range(h):
    minlist.append(min(a[i]))
    suma.append(sum(a[i]))
print(sum(suma)-(min(minlist)*h*w))
66e6359405eb4cc180305664f8090fe6b42c88dd
<mask token>

<mask token>
for i in range(h):
    minlist.append(min(a[i]))
    suma.append(sum(a[i]))
print(sum(suma) - min(minlist) * h * w)

h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
minlist = []
suma = []
for i in range(h):
    minlist.append(min(a[i]))
    suma.append(sum(a[i]))
print(sum(suma) - min(minlist) * h * w)

h ,w = map(int,input().split())
a = [list(map(int, input().split())) for i in range(h)]
minlist = []
suma = []
for i in range(h):
    minlist.append(min(a[i]))
    suma.append(sum(a[i]))
print(sum(suma)-(min(minlist)*h*w))