Kattis, Speed limit; read irregular input
Your approach to the problem seems very imperative and whole-problem focused. Thinking in Haskell generally benefits from considering more bottom-up strategies, using smaller, easily tested, reusable pieces.

Right off the bat, your representation of the core datatype (a log of speeds and timestamps) seems ill-fitted. A list of list of Ints doesn't capture the fact that you know you will only be receiving pairs of numbers at a time.

type Speed = Int
type Timestamp = Int
type LogLine = (Speed, Timestamp)
type Log = [LogLine]

-- Less vitally...
type Logs = [Log]


Type aliases help provide documentation to readers of your code (including you as you write it, or come back to it after any significant stretch of time), use them liberally when working with the basic datatypes. The above set of aliases captures the input as it will be given to you (post- the act of parsing). Lists of pairs of numbers in the string input become []s of (,)s of Ints in Haskell.

Next we have to determine what sort of format we want to transform the data into in order to calculate an answer from it. The problem would be simple if we could replace those timestamps with durations, so we'll figure out a way to do that.

type Duration = Int

durations :: [Timestamp] -&gt; [Duration]


Note that speeds won't be relevant when converting timestamps to durations, but we will need all of the timestamps in a log in order.

Once we have speed and duration pairs, solving for the solution should be easy.

type Distance = Int

calculate :: [(Speed, Duration)] -&gt; Distance
calculate = sum . map (uncurry (*))


And if we hop in GHCi and test that definition with some hand-crafted data (i.e., the worked example given in the problem statement)—


λ sum . map (uncurry (*)) $ [(20, 2), (30, 4), (10, 1)]
170



Looks good. Now we work backward, filling in the pieces we left undefined, and combining them together as appropriate.

durations :: [Timestamp] -&gt; [Duration]
durations ts = zipWith (-) ts (0:ts)

solve :: Log -&gt; Distance
solve ls =
  let (speeds, timestamps) = unzip ls
  in  calculate $ zip speeds (durations timestamps)


With a little more consideration (and certainly if we were willing to pull in the lens library) we could code golf the unzip/zip away and end up with a pithy one liner for solve, but often the most straightforward solution is more than adequate.

Now we need only deal with the parsing and pretty-printing aspects of the problem. Given that all of these code challenge tasks are similar, much of this is boilerplate you reuse from problem to problem, just make sure you're familiar with the contents of the Control.Monad module.

main :: IO ()
main = do
  n &lt;- readLn
  if n == -1
  then return () -- End flag, don't recurse
  else do
    log &lt;- replicateM n $ do
      [speed, timestamp] &lt;- map read . words &lt;$&gt; getLine
      return (speed, timestamp)
    let distance = solve log
    putStrLn $ (show distance) ++ " miles"
    main -- recurse, look for the next trip