#include <bits/stdc++.h>
using namespace std;
int n, w[100005], p[100005], ans;
int main () {
freopen ("asm_algo.in", "r", stdin);
freopen ("asm_algo.out", "w", stdout);
cin >> n >> w[1];
for (int i = 2; i <= n; i++) {
cin >> p[i] >> w[i];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
ans = ans + i * j * max(i, j);
}
}
cout << ans << endl;
return 0;
}