public class Hello{
public static void Main(){
// 自分の得意な言語で
// Let's チャレンジ!!
var line = int.Parse(System.Console.ReadLine());
long total = 0;
for (var i=0; i<line; i++)
{
var buf = System.Console.ReadLine().Split(' ');
var needs = int.Parse(buf[0]);
var current = int.Parse(buf[1]);
var amount = int.Parse(buf[2]);
if (current < needs)
{
total += (needs - current) * amount;
}
}
System.Console.WriteLine("{0}", total);
}
}