def intSum(arcs,A): s = 0 for a in A: for arc in arcs: i = intervalIntersection(arc[1:],a) if i: s += i[1] - i[0] return s