CF915F Imbalance Value of a Tree

Description

You are given a tree $ T $ consisting of $ n $ vertices. A number is written on each vertex; the number written on vertex $ i $ is $ a_{i} $ . Let's denote the function $ I(x,y) $ as the difference between maximum and minimum value of $ a_{i} $ on a simple path connecting vertices $ x $ and $ y $ . Your task is to calculate ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF915F/3e8bb6339f453c71e01dfafe23a705f11b574a3a.png).

Input Format

The first line contains one integer number $ n $ ( $ 1

Output Format

Print one number equal to ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF915F/3e8bb6339f453c71e01dfafe23a705f11b574a3a.png).