#include <bits/stdc++.h>
using namespace std;
vector<int> mg[100005];
int marka[100005], n, vazan, D1, D2, SD, P, otac[100005], st_od_rast[100005];
int RAST, dp[100005][3], duzd;
void dfs1(int cvor, int r) {
  int i, x;
  marka[cvor] = 1;
  for (i = 0; i < mg[cvor].size(); i++) {
    x = mg[cvor][i];
    if (marka[x] == 0) {
      int t = mg[x].size();
      if (st_od_rast[r + 1] == 0)
        st_od_rast[r + 1] = t;
      else if (st_od_rast[r + 1] != t)
        vazan = -1;
      dfs1(x, r + 1);
    }
  }
}
int probaj(int cvor) {
  int i;
  for (i = 1; i <= n; i++) {
    st_od_rast[i] = 0;
    marka[i] = 0;
  }
  vazan = cvor;
  dfs1(cvor, 0);
  return vazan;
}
void dfs(int cvor) {
  int i, x;
  marka[cvor] = 1;
  for (i = 0; i < mg[cvor].size(); i++) {
    x = mg[cvor][i];
    if (marka[x] == 0) {
      otac[x] = cvor;
      dfs(x);
    }
  }
  if (mg[cvor].size() == 1) {
    dp[cvor][1] = 0;
    dp[cvor][2] = cvor;
  } else {
    int a = 0, b = 0, ac = 0, bc = 0;
    for (i = 0; i < mg[cvor].size(); i++) {
      x = mg[cvor][i];
      if (x == otac[cvor]) continue;
      if (dp[x][1] + 1 > a) {
        b = a;
        bc = ac;
        a = dp[x][1] + 1;
        ac = dp[x][2];
      } else if (dp[x][1] + 1 > b) {
        b = dp[x][1] + 1;
        bc = dp[x][2];
      }
    }
    dp[cvor][1] = a;
    dp[cvor][2] = ac;
    if (a + b > duzd) {
      duzd = a + b;
      D1 = ac;
      D2 = bc;
    }
  }
}
void dfs2(int cvor, int r) {
  int i, x;
  marka[cvor] = 1;
  for (i = 0; i < mg[cvor].size(); i++) {
    x = mg[cvor][i];
    if (marka[x] == 0) {
      otac[x] = cvor;
      dfs2(x, r + 1);
    }
  }
  for (i = 0; i < mg[cvor].size(); i++) {
    x = mg[cvor][i];
    if (x == otac[cvor]) continue;
    dp[cvor][1] = max(dp[cvor][1], dp[x][1] + 1);
  }
  if (r == duzd / 2 && dp[cvor][1] == duzd / 2) SD = cvor;
}
void nadji(int cvor, int r) {
  int i, x;
  marka[cvor] = 1;
  for (i = 0; i < mg[cvor].size(); i++) {
    x = mg[cvor][i];
    if (marka[x] == 0 && mg[x].size() <= 2) {
      otac[x] = cvor;
      nadji(x, r + 1);
    }
  }
  if (r < RAST && mg[cvor].size() == 1) {
    P = cvor;
    RAST = r;
  }
}
int main() {
  int res = -1, i, a, b;
  D1 = 1;
  D2 = 1;
  P = 1;
  SD = 1;
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> a >> b;
    mg[a].push_back(b);
    mg[b].push_back(a);
  }
  duzd = 0;
  dfs(1);
  SD = 1;
  if (res == -1) res = probaj(D1);
  if (res == -1) res = probaj(D2);
  for (i = 1; i <= n; i++) {
    marka[i] = 0;
    otac[i] = 0;
    dp[i][1] = 0;
  }
  dfs2(D1, 0);
  if (res == -1) res = probaj(SD);
  RAST = n;
  for (i = 1; i <= n; i++) {
    marka[i] = 0;
    otac[i] = 0;
    dp[i][1] = 0;
  }
  nadji(SD, 0);
  if (res == -1) res = probaj(P);
  if (n == 1) res = 1;
  if (res == 0)
    cout << D1 << " " << D2 << " " << SD << " " << P << endl;
  else
    cout << res;
  return 0;
}
