#include #include #include #include #include #include #include #include using namespace std; const int maxn = 1005; typedef long long ll; int dp[maxn][maxn]; ll pref_sum[maxn]; int rec(int i, int j) { for(int k = i; k < j; k++) { if(pref_sum[k] * 2 == pref_sum[j] + pref_sum[i - 1]) { return max(rec(i, k), rec(k + 1, j)) + 1; } } return 0; } int main() { ios_base::sync_with_stdio(false); int t; cin >> t; while(t--) { memset(pref_sum, 0, sizeof pref_sum); int n; cin >> n; ll s = 0; for(int i = 1 ; i <= n; i++) { cin >> pref_sum[i]; pref_sum[i] += pref_sum[i - 1]; } cout << rec(1, n) << endl; } return 0; } /* 5 9 7 ...##.... ..#.##..# ..#....## .##...#.. ....#.... WS?EE?? **/