using System; public class Program { public static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); TimeSpan timeSpan = new TimeSpan(0, 0, 0); for (int i = 0; i < n; i++) { string[] s = Console.ReadLine().Split(' '); DateTime a = DateTime.Parse(s[0]); DateTime b = DateTime.Parse(s[1]); if (a > b) { b = b.AddHours(24); } timeSpan += b - a; } Console.WriteLine(timeSpan.TotalMinutes); } }