q = io.read("*n") t = {} for iq = 1, q do for i = 1, 5 do t[i] = io.read("*n") end table.sort(t) print(t[5] - t[1]) end