There are three arrays a, b and c. Each of them consists of n integers. SmallY wants to find three integers u, v, w (0 ≤ u, v, w ≤ n) such that the following condition holds: each number that appears in the union of a, b and c, appears either in the first u elements of a, or in the first v elements of b, or in the first w elements of c. Of course, SmallY doesn't want to have huge numbers u, v and w, so she wants sum u + v + w to be as small as possible.

Please, help her to find the minimal possible sum of u + v + w.

Input

The first line contains a single integer n (1 ≤ n ≤ 105). The second line contains n space-separated integers a1, a2, ..., an — array a. The third line contains the description of array b in the same format. The fourth line contains the description of array c in the same format. The following constraint holds: 1 ≤ ai, bi, ci ≤ 109.

Output

Print a single integer — the minimum possible sum of u + v + w.

Examples

Input

3
1 1 101
1 2 1
3 2 1


Output

5

Input

5
1 1 2 2 3
2 2 4 3 3
3 3 1 1 1


Output

5

Note

In the first example you should choose u = 3, v = 0, w = 2. 

In the second example you should choose u = 1, v = 3, w = 1.
1
2
3
2
 8
190409007 190409007 352375776 190409007 352375776 352375776 352375776 352375776
190409007 190409007 190409007 190409007 190409007 352375776 352375776 190409007
190409007 352375776 352375776 190409007 190409007 190409007 352375776 352375776
 1
1
1
1
 1
377489979
588153796
588153796
 2
1 1
2 2
3 3
 4
1 1 1 1
1 1 1 1
1 1 1 1
 2
1 2
2 2
1 1
 3
1 1 2
1 1 3
1 1 4

2
 2
 1
 2
 3
 1
 2
 9

#include <bits/stdc++.h>
using namespace std;
int l;
int a[(300005)], b[(300005)], c[(300005)];
int dc[(300005) * 3], ldc = 0, ll;
int A[(300005) * 3], B[(300005) * 3], C[(300005) * 3];
int idx[(300005) * 3];
bool cmp(int x, int y) { return A[x] > A[y]; }
void INIT() {
  scanf("%d", &l);
  for (int i = 0; i < l; i++) scanf("%d", &a[i]), dc[ldc++] = a[i];
  for (int i = 0; i < l; i++) scanf("%d", &b[i]), dc[ldc++] = b[i];
  for (int i = 0; i < l; i++) scanf("%d", &c[i]), dc[ldc++] = c[i];
  sort(dc, dc + ldc);
  ll = unique(dc, dc + ldc) - dc;
}
void PREP() {
  for (int i = 0; i < l; i++) a[i] = lower_bound(dc, dc + ll, a[i]) - dc;
  for (int i = 0; i < l; i++) b[i] = lower_bound(dc, dc + ll, b[i]) - dc;
  for (int i = 0; i < l; i++) c[i] = lower_bound(dc, dc + ll, c[i]) - dc;
  for (int i = 0; i < ll; i++) A[i] = B[i] = C[i] = 5 * (300005);
  A[ll] = 0;
  for (int i = 0; i < l; i++)
    if (A[a[i]] > (300005)) A[a[i]] = i + 1;
  for (int i = 0; i < l; i++)
    if (B[b[i]] > (300005)) B[b[i]] = i + 1;
  for (int i = 0; i < l; i++)
    if (C[c[i]] > (300005)) C[c[i]] = i + 1;
  for (int i = 0; i < ll + 1; i++) idx[i] = i;
  sort(idx, idx + ll, cmp);
}
multiset<int> pro;
set<pair<int, int> > st;
void ins(pair<int, int> x) {
  set<pair<int, int> >::iterator tmp = st.lower_bound(x);
  if (tmp->second >= x.second) return;
  set<pair<int, int> >::iterator tmp2 = st.insert(x).first;
  set<pair<int, int> >::iterator tmp3 = tmp2;
  tmp3--;
  pro.erase(pro.lower_bound(tmp3->first + tmp->second));
  pro.insert(tmp2->first + tmp->second);
  while (tmp2->second > tmp3->second) {
    set<pair<int, int> >::iterator tmp4 = tmp3--;
    pro.erase(pro.lower_bound(tmp3->first + tmp4->second));
    st.erase(tmp4);
  }
  pro.insert(tmp2->second + tmp3->first);
}
void PROCESS() {
  int ans = (300005) * 10;
  st.insert(pair<int, int>(0, (300005) * 10)),
      st.insert(pair<int, int>((300005) * 10, 0)), pro.insert(0);
  for (int i = 0; i < ll; i++) {
    ins(pair<int, int>(B[idx[i]], C[idx[i]]));
    ans = min(ans, A[idx[i + 1]] + *pro.begin());
  }
  printf("%d\n", ans);
}
int main() {
  INIT();
  PREP();
  PROCESS();
  return 0;
}
