#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;
using P = pair<int, int>;

// 1次元 vector
template <class T>
ostream &operator<<(ostream &s, vector<T> vec) {
    for (int i = 0; i < (int)vec.size(); ++i) {
        if (i > 0) {
            s << " ";
        }
        s << vec[i];
    }
    return s << endl;
}
template <class T>  // 2次元 vector
ostream &operator<<(ostream &s, vector<vector<T>> vec2) {
    for (int i = 0; i < (int)vec2.size(); ++i) {
        s << vec2[i];
    }
    return s;
}

// set
template <class T>
ostream &operator<<(ostream &s, set<T> se) {
    for (auto i : se) {
        s << "(" << i << ") ";
    }
    return s << endl;
}

// map
template <class T1, class T2>
ostream &operator<<(ostream &s, map<T1, T2> ma) {
    for (auto p : ma) {
        s << "(" << p.first << "->" << p.second << ") ";
    }
    return s << endl;
}

// pair
template <class T1, class T2>
ostream &operator<<(ostream &s, pair<T1, T2> p) {
    s << "(" << p.first << "->" << p.second << ") ";
    return s << endl;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    map<int, int> ma, mb;
    for (int i = 0; i < N; i++) {
        ma[A[i]]++;
        mb[B[i]]++;
    }

    vector<P> T;
    for (auto p : ma) {
        T.push_back(P(p.second, p.first));
    }
    sort(T.begin(), T.end(), greater<P>());

    vector<int> newA;
    for (auto p : T) {
        for (int i = 0; i < p.first; i++) {
            newA.push_back(p.second);
        }
    }

    vector<P> ids(N);
    for (int i = 0; i < N; i++) {
        ids[i] = P(newA[i], i);
    }
    sort(ids.begin(), ids.end());

    vector<int> newB;
    for (auto p : T) {
        for (int i = 0; i < mb[p.second]; i++) {
            newB.push_back(p.second);
        }
        mb[p.second] = 0;
    }
    for (auto p : mb) {
        for (int i = 0; i < p.second; i++) {
            newB.push_back(p.first);
        }
    }
    reverse(newB.begin(), newB.end());

    int dup = 0;
    for (int i = 0; i < N; i++) {
        if (newA[i] == newB[i]) {
            dup = newA[i];
            break;
        }
    }

    if (dup > 0) {
        int al = 0, ar = N, bl = 0, br = N;  // 半開区間
        for (int i = 0; i < N; i++) {
            if (newA[i] == dup) {
                al = i;
                for (; i < N && newA[i] == dup; i++)
                    ;
                ar = i;
            }
        }
        for (int i = 0; i < N; i++) {
            if (newB[i] == dup) {
                bl = i;
                for (; i < N && newB[i] == dup; i++)
                    ;
                br = i;
            }
        }
        //cerr << al << " " << ar << endl;
        //cerr << bl << " " << br << endl;
        queue<int> canswap;
        for (int i = 0; i < min(al, bl); i++) {
            canswap.push(i);
        }
        for (int i = max(ar, br); i < N; i++) {
            canswap.push(i);
        }

        int dl = max(al, bl);
        int dr = min(ar, br);
        if ((int)canswap.size() < dr - dl) {
            cout << "No" << endl;
            return 0;
        }
        for (int i = dl; i < dr; i++) {
            int j = canswap.front();
            canswap.pop();
            swap(newB[i], newB[j]);
        }
    }

    vector<int> ans(N);
    for (int i = 0; i < N; i++) {
        ans[i] = newB[ids[i].second];
    }

    cout << "Yes" << endl;
    cout << ans << endl;
}


Measured memory_bytes: 30072