//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)

const int M=1000000007;
const int MM=998244353;


 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=2e5+5;

struct segtree{

int size;

vpii nums;

void initialize(ll n){
  size=1;
  while(size<n)size*=2;
  nums.assign(2*size,{M,0});
}

/*
x->index of node .
it covers the segment [lx,rx-1]

*/

void build(vi& a,int x,int lx,int rx)
{
  if(rx-lx==1){
    if(lx<a.size())nums[x]={a[lx],1};
      return;
  }
  int m=(lx+rx)/2;
  build(a,2*x+1,lx,m);
  build(a,2*x+2,m,rx);

  int m1=nums[2*x+1].ff;
int c1=nums[2*x+1].ss;

int m2=nums[2*x+2].ff;
int c2=nums[2*x+2].ss;

//
 if(m1<m2)nums[x]={m1,c1};
else if(m2<m1) nums[x]={m2,c2};

else nums[x]={m1,c1+c2};


}

void build(vi& a){
  build(a,0,0,size);
}



/*

ll sum(ll x,ll lx,ll rx,ll l,ll r){
  if(lx>=l&&rx<=r){
    return nums[x];
  }
  if(rx<=l||lx>=r){
    return 0;
  }
  ll m=(lx+rx)/2;
  ll sum1=sum(2*x+1,lx,m,l,r);
  ll sum2=sum(2*x+2,m,rx,l,r);
  return sum1+sum2;
}

ll sum(ll l,ll r){
  return sum(0,0,size,l,r);
}

*/

void set(int i,int v,int x,int lx,int rx){

if(rx-lx==1){
 nums[x]={v,1};
  return;
}

int m=(lx+rx)/2;

if(i<m)set(i,v,2*x+1,lx,m);
else set(i,v,2*x+2,m,rx);

int m1=nums[2*x+1].ff;
int c1=nums[2*x+1].ss;

int m2=nums[2*x+2].ff;
int c2=nums[2*x+2].ss;

//
 if(m1<m2)nums[x]={m1,c1};
else if(m2<m1) nums[x]={m2,c2};

else nums[x]={m1,c1+c2};


}

void set(int i,int v){
  set(i,v,0,0,size);
}

pii findmin(int l,int r,int x,int lx,int rx){

if(lx>=l&&rx<=r)return nums[x];
if(lx>=r||rx<=l)return {M,0};

int m=(lx+rx)/2;

int m1=findmin(l,r,2*x+1,lx,m).ff;
int c1=findmin(l,r,2*x+1,lx,m).ss;
int m2=findmin(l,r,2*x+2,m,rx).ff;
int c2=findmin(l,r,2*x+2,m,rx).ss;


 if(m1<m2)return {m1,c1};
else if(m2<m1) return {m2,c2};
else return {m1,c1+c2};
}

pii findmin(ll l,ll r){
  return findmin(l,r,0,0,size);
}


};


int main()
{ 

IOS;

ll n;cin>>n;

ll ret=0;

for(ll i=1;i<=n;i++)ret+=i*(i+1)/2;

ll m=n-1;
while(m--){
  ll a,b;cin>>a>>b;
  if(a>b)swap(a,b);
  ret-=(a)*(n-b+1);
}

cout<<ret<<endl;


return 0;
 
}


Measured memory_bytes: 3620