// print()    -> p();
// println()  -> pn();
// next()     -> ns();
// nextInt()  -> ni();
// nextLong() -> nl();
import java.io.*;
import java.util.*;

public class Main {

    static void solve() {
        int n = ni();

        // if(n <= 2) {
        //     pn("NO");
        //     return;
        // }

        int[] f = new int[100001];

        int max1 = -1, max2 = -1;
        for(int i = 0; i < n; i++) {
            int val = ni();
            f[val]++;
            
            if(max1 < val) {
                max2 = max1;
                max1 = val;
            }

            else if(max2 < val) {
                max2 = val;
            }
        }
        
        if(max1 != max2){
            if(f[max1] + f[max2] < n) pn("YES");
            else pn("NO");
        }
        
        else{
            if(2 * f[max1] <= n + 1) pn("YES");
            else pn("NO");
        }
    }

    public static void main(String[] args) throws Exception {
        int T = ni();

        while (T-- > 0) {
            solve();
        }

        out.flush();
        out.close();
    }

    // gcd
    static long gcd(long a, long b) {
        return (b == 0) ? a : gcd(b, a % b);
    }

    // modular a^b
    static long modPow(long a, long b, long mod) {
        long res = 1;
        while (b > 0) {
            if ((b & 1) == 1) res = (res * a) % mod;
            a = (a * a) % mod;
            b >>= 1;
        }
        return res;
    }

    // global io
    static FastReader in = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);

    // mod = (int)1e9+ 7
    static final int MOD = 1_000_000_007;

    // short input methods
    static String ns() {
        return in.next();
    }
    static int ni()  {
        return in.nextInt();
    }
    static long nl() {
        return in.nextLong();
    }

    // short output methods
    static void p(Object o)  {
        out.print(o);
    }
    static void pn(Object o) {
        out.println(o);
    }

    // fast reader
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()   {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}