private static int lastInsertionPoint(int[] array, int key) {
    int l = 0;
    int u = array.length - 1;
    while (u > l) {
      int middle = (l + u) / 2;
      if (array[middle] <= key) {
        l = middle + 1;
      }
      else {
        u = middle;
      }
    }
    assert l == u;
    return l;
  }
private static int lastInsertionPoint(int[] array, int key)