Duration in continuous dates : Server   Customer.              Start.                          End
A.                X.         12/10/2018 12:56    13/10/2018. 13:05
B.               K.         12/10/2018 14:05.   12/10/2018.  14:25
A.               N      12/10/2018.  13:08.   13/10/2018. 17:09
A.                Y      15/10/2018.  16:07.    17/10/2018. 14:09
A.              F.        18/10/2018 13:05.      18/10/2018 20:09

I want how much duration server A was used 12/10/2018 12:56 to 18/10/2018 20:09. And how much time it was idle i.e 13/10/2018 17:09 to 15/10/2018 16:07 duration + 17/10/2018 14:09 to 18/10/2018. If any customer is login then that time is not counted as idle. How can I do it in Excel or Google sheets 