code: public static long[] insertEntry(long[] a, int idx, long val) {
          long[] b = new long[a.length + 1];
          for (int i = 0; i < b.length; i++) {
              if (i < idx) {
                  b[i] = a[i];
              } else if (i == idx) {
                  b[idx] = val;
              } else {
                  b[i] = a[i - 1];
              }
          }
          return b;
      }
docs: Gets a copy of the array with an entry inserted.
  
  @param a The input array.
  @param idx The position at which to insert.
  @param val The value to insert.
  @return A new array with the inserted value.