ior = io.read local n = ior("*n") local t = {} local cnt = 0 for i = 1, n do local a = ior("*n") if(t[a] == nil) then cnt = cnt + 1 t[a] = 1 else t[a] = t[a] + 1 end end if(cnt <= 2) then print(0) else local ret = (cnt * (cnt - 1) / 2) % 1000000007 ret = (ret * (cnt - 2) / 3) % 1000000007 for k, v in pairs(t) do ret = (ret * v) % 1000000007 end print(ret) end