#include /* C++(GCC++17) Template for Programming-Contest. author : sgsw generated : 2021/08/14 when : 22:55:57 */ using namespace std; #pragma GCC optimize("Ofast") #define ll long long #define ld long double #define rep(i, a, b) for (int i = a; i < b; i++) #define rep1(i, a, b) for (int i = (b) - 1; i >= a; i--) #define endl '\n' #define vvii vector> #define vi vector #define vvll vector> #define vl vector template ostream& operator << (ostream &s, vector &P) { for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; } template bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;} template T gcd(T a, T b){return (b == 0) ? a : gcd(b, a % b);} template T lcm(T a, T b){return a / gcd(a, b) * b;} templateT powMod(T x, T k, T m) {if (k == 0){return (T)1;}if (k % 2 == 0) {return powMod(x*x % m, k/2, m);}else{return x*powMod(x, k-1, m) % m;}} template T extgcd(T a,T b,T &x,T &y){T g = a;x = 1;y = 0;if (b != 0) {g = extgcd(b, a % b, y, x), y -= (a / b) * x;}return g;} template T invMod(T a,T m){T x,y;if (extgcd(a, m, x, y) == 1) {return (x + m) % m;}else{return -1;}} using Pii = pair; using Pll = pair; const int inf = 1e9; const ll mod = int(1e9 + 7); signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector> g(n); rep(i,0,n - 1){ int u,v; cin >> u >> v; u--;v--; g[u].emplace_back(v); g[v].emplace_back(u); } vector child(n); vector par(n,-1); vector dist(n,inf); int S = 0;dist[S] = 0; ll ans = 0; //step 1. dfs_1 function dfs = [&](int u){ for (int v : g[u]){ if (dist[v] == inf){ dist[v] = dist[u] + 1; par[v] = u; dfs(v); } } child[u]++; for (int v : g[u]){ if (v == par[u])continue; child[u] += child[v]; } ans += child[u]; }; dfs(S); //step 2. dfs_2 ll final_ans = 0; dist.assign(n,inf); dist[S] = 0; function dfs2 = [&](int u){ final_ans = (final_ans + ans) % mod; for (int v : g[u]){ if (dist[v] == inf){ dist[v] = dist[u] + 1; ans += n - 2 * child[v]; dfs2(v); } } ans -= n - 2 * child[u]; }; dfs2(S); printf("%d\n",final_ans); return 0; }