/*
Jackson Simoneau
SI@UCF 2026 - Intro to Competitive Programming

Solution to Deletion Sort (B): https://codeforces.com/contest/2200/problem/B
Explanations: https://codeforces.com/blog/entry/151625
*/

#include <bits/stdc++.h>
using namespace std;

int main() {
    //Process test cases
    int t; cin >> t;
    while(t--) {
        int n; cin >> n;
        vector<int> a(n);
        for(int i = 0; i < n; i++) {
            cin >> a[i];
        }
        //Check if there are two adjacent values where the second is smaller than the first
        bool dec = false;
        for(int i = 1; i < n; i++) {
            if(a[i] < a[i-1]) dec = true;
        }
        //If this occurs, we can remove all elements except one of these two
        if(dec) cout << 1 << '\n';
        //Otherwise, the array is already non-decreasing so we cannot perform any operations
        else cout << n << '\n';
    }
}