public static void Main()
Console.WriteLine("Please enter the height of the column.(-1 will be the last column)");
int nextColumnHeight = Convert.ToInt32(Console.ReadLine());
while (nextColumnHeight != -1)
if (maxColumnHeight < nextColumnHeight)
maxColumnHeight = nextColumnHeight;
r += maxColumnHeight - nextColumnHeight;
nextColumnHeight = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Water capacity = " + r);