Fuel app - calculate distance

Hi,

I have made an simple app, where i input the Kilometers of my car, when i put fuel on the tank.
I have made a simple Google Sheet and it works fine.
Titles on row 1, and data entered starts from row 2

I want to calculate the trip (Distance) just by Substracting the previous Kilometers with the newly entered.

If i enter Kilometers in the A column - i just want it to automatically substract A3 - A2
And the next time i enter the kilometers, it should substract A4 - A3 and so on.

I have tried to make an arrayformula in column E2 direct in Google Sheets:
=ArrayFormula(A3:A-A2:A)

But it keeps failing with #REFERENCE

Please help.

Thanks in advance.
/René

I actually have an app that does this, but I only use glide tables and all functionality is within glide. You can do the math in the Google sheet, but you would probably run into issues if you ever start deleting rows. Plus the formula gets ugly because you have to deal with prior rows and if it’s the first row, then it might throw an error.

Instead my app is entirely driven by the user table, but the fuel log is written to a different table. What I have is a relation to the fuel table and then I do a rollup to get the max odometer reading for the vehicle. Then in my form I pass in that rollup value and write it to a new fuel log row as a previous odometer reading along with the current odometer reading that the user enters. Then I have a math column that calcuates distance and miles per gallon.