// #define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

bool is_prime(int n) {
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) return false;
  }
  return true;
}

int main() {
  vector<int> p;
  for (int i = 2; i <= 50; ++i) {
    if (is_prime(i)) p.push_back(i);
  }
  trace(p, SZ(p));
  int n, m = SZ(p);
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    for (int j = 0; j < SZ(p); ++j) {
      if (x % p[j] == 0) a[i] |= 1 << j;
    }
  }
  trace(a);
  int64 ret = inf<int64>;
  for (int k = 1; k < (1 << m); ++k) {
    bool ok = true;
    for (int i = 0; i < n; ++i) {
      if ((k & a[i]) == 0) {
        ok = false;
        break;
      }
    }
    if (ok) {
      int64 cur = 1;
      for (int i = 0; i < m; ++i) {
        if ((k >> i) & 1) cur *= p[i];
      }
      // trace(k, cur);
      ret = min(ret, cur);
    }
  }
  cout << ret << '\n';
  return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define ll long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a))
#define FOREACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define dbg(x) cout << (#x) << " is " << (x) << endl;
#define dbg2(x, y) cout << (#x) << " is " << (x) << " and " << (#y) << " is " << y << endl;
#define dbgarr(x, sz)                                             \
  for (int asdf = 0; asdf < (sz); asdf++) cout << x[asdf] << ' '; \
  cout << endl;
#define dbgarr2(x, rose, colin)                \
  for (int asdf2 = 0; asdf2 < rose; asdf2++) { \
    dbgarr(x[asdf2], colin);                   \
  }
#define dbgitem(x)                                                           \
  for (auto asdf = x.begin(); asdf != x.end(); asdf++) cout << *asdf << ' '; \
  cout << endl;

const int mod = 3, MAXN = 2e5 + 1;

int n, diam_kid[MAXN];
vi adj[MAXN];
struct Solution {
  vi res;
  int t = 1;
  pii diam;
  void solve() {
    res.resize(n), memset(diam_kid, -1, sizeof(diam_kid));
    diam = get_diameter(0);
    // dbg2(diam.first, diam.second);
    dfs(diam.first, -1);
    walk(diam.first, -1);
  }
  void walk(int i, int p) {
    res[i] = t++;
    for (int j : adj[i]) {
      if (j == p || j == diam_kid[i]) continue;
      walk(j, i);
    }
    if (diam_kid[i] != -1) walk(diam_kid[i], i);
    t++;  // revisit
  }
  bool dfs(int i, int p) {  // track which kid leads to the other endpoint of the diameter
    if (i == diam.second) return true;
    for (int j : adj[i]) {
      if (j == p) continue;
      if (dfs(j, i)) diam_kid[i] = j;  // j leads to diam.second
    }
    return diam_kid[i] != -1;
  }
  pii get_diameter(int i) {  // returns diam from the region i is in
    auto p = farthest(i, 0, -1);
    return {farthest(p.second, 0, -1).second, p.second};
  }
  pii farthest(int i, int d, int p) {  // returns {dist, node} farthest from i; d= dist from source node
    pii res = {d, i};
    for (int j : adj[i]) {
      if (j == p) continue;
      res = max(res, farthest(j, d + 1, i));
    }
    return res;
  }
};
void print(vector<int>& nums) {
  for (auto num : nums) cout << num << " ";
  cout << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  Solution test;
  int a, b;
  cin >> n;
  REP(i, n - 1)
  cin >> a >> b,
      adj[--a].push_back(--b), adj[b].push_back(a);
  test.solve();
  print(test.res);
}