class SumToOne {

  protected static int[][] getSet(final int n) {
    ArgumentChecker.isTrue(n > 1, "need n>1");
    if (SETS.containsKey(n)) {
      return SETS.get(n);
    }
    int[][] res = new int[n][];
    switch (n) {
      case 2:
        res[0] = new int[] {1 };
        res[1] = new int[] {-1 };
        break;
      case 3:
        res[0] = new int[] {1, 0 };
        res[1] = new int[] {-1, 1 };
        res[2] = new int[] {-1, -1 };
        break;
      case 4:
        res[0] = new int[] {1, 1, 0 };
        res[1] = new int[] {1, -1, 0 };
        res[2] = new int[] {-1, 0, 1 };
        res[3] = new int[] {-1, 0, -1 };
        break;
      default:
        final int n1 = n / 2;
        final int n2 = n - n1;
        final int[][] set1 = getSet(n1);
        final int[][] set2 = (n1 == n2 ? set1 : getSet(n2));
        res = new int[n][n - 1];

        for (int i = 0; i < n1; i++) {
          res[i][0] = 1;
          System.arraycopy(set1[i], 0, res[i], 1, n1 - 1);
        }
        for (int i = 0; i < n2; i++) {
          res[i + n1][0] = -1;
          System.arraycopy(set2[i], 0, res[i + n1], n1, n2 - 1);
        }
    }
    SETS.put(n, res);
    return res;
  }

  public  SumToOne(final int n);

}