Problem Statement:
Codeforces Round #353 (Div. 2) - E. Trains and StatisticSummary:
A graph with node 1..n such that node i have an edge to every nodes in i+1 to a[i] inclusive (where i+1 <= a[i] <= n). Calculate the sum of all the length shortest path from every pair of nodes.