# Include <stdio. h> # include <string. h ># include <algorithm> using namespace std; int n, map [70], v [70]; int sum; // The length of all wood rods and int total, length, flag; bool cmp (int x, int y) {return x> y;} // num indicates the number of wood sticks, and len indicates the length of the wood sticks, pos indicates the position of the stick void dfs (int num, int len, int pos) {if (num = total) {flag = 1; return ;}if (flag) return; for (int I = pos; I <n; I ++) {if (v [I]) continue; if (map [I] + len = length) {v [I] = 1; dfs (num +, 0); // a wood rod is successfully combined. num + 1 v [I] = 0 ;} else if (map [I] + len <length) {v [I] = 1; dfs (num, map [I] + len, I + 1 ); v [I] = 0; if (len = 0) return;/* if the length of the front edge is 0 during the current search, and the first root fails to be used, this indicates that the first root is always discarded, so this combination will not succeed */while (map [I] = map [I + 1]) // if this does not meet the requirements, the same length does not meet the requirements. Skip I ++ ;}} int main () {int I; while (scanf ("% d", & n) & n) {sum = 0; for (I = 0; I <n; I ++) {scanf ("% d", & map [I]); sum + = map [I];} memset (v, 0, sizeof (v); sort (map, map + n, cmp ); // sort the sticks from the upper to the lower for (length = map [0]; length <= sum; length ++)/* search for the sticks with the longest length, because the minimum length of the combined wooden rod is greater than or equal to the longest root */{if (sum % length) continue; // if it cannot be divisible, it cannot constitute an integer. The root stick flag = 0; // mark total = sum/length; // The length after the combination with length, total indicates the number of wood sticks obtained dfs (, 0); if (flag) {printf ("% d \ n", length); break ;}} return 0 ;}