Using the digits 0,1,2,3,4, all four-digit numbers are formed with no digit repeated. A number may not begin with 0, so 0123 is not a four-digit number. Each such number is written down exactly once. Let S be the sum of all these four-digit numbers. Find the value of S.