I want to get rid of unneccessary repetiton of cycles
DRY = Don't Repeat Yourself.
If you have repeating parts of code, something went wrong then. Also you may use Linq.
Consider this example.
static void Main(string[] args)
{
    string[] lines = File.ReadAllLines(@&quot;C:\temp\andmed2&quot;);
    List&lt;int&gt; numbersList = lines.Select(line =&gt; int.Parse(line)).OrderByDescending(x =&gt; x).ToList();
    int sum = numbersList.Aggregate(0, (x, y) =&gt; x + y);
    int numberOfStacks = numbersList.Count;

    List&lt;int&gt; repeatedBarrelSizes = numbersList;
    int count;
    do
    {
        count = 0;
        List&lt;int&gt; result = new List&lt;int&gt;();
        for (int i = 0; i &lt; repeatedBarrelSizes.Count - 1; i++)
        {
            if (repeatedBarrelSizes[i] &gt; repeatedBarrelSizes[i + 1])
                count++;
            else if (repeatedBarrelSizes[i] == repeatedBarrelSizes[i + 1])
                result.Add(repeatedBarrelSizes[i + 1]);
        }
        repeatedBarrelSizes = result;
        numberOfStacks -= count;
    } while (count &gt; 0);

    Console.WriteLine(string.Join(&quot; &quot;, repeatedBarrelSizes));

    Console.WriteLine(&quot;Sum: &quot; + sum);
    Console.WriteLine(&quot;Number of barrels: &quot; + numbersList.Count);
    Console.WriteLine(&quot;Stacks: &quot; + numberOfStacks);
}

I'm sorry but I can't test it because I have no source file with numbers to compare the results.
Total: two loops.