Skip to main content
2 of 3
fixed to support any length / saved 4 bytes
Arnauld
  • 197.7k
  • 20
  • 179
  • 650

JavaScript (ES6), 36 bytes

Expects an array of prices.

a=>a.reduce((t,v,i)=>t+=p-=v*~i,p=0)

Try it online!

Arnauld
  • 197.7k
  • 20
  • 179
  • 650