Please see the reprex FAQ for information on how to attract more and better answers.
values <- c(21, 63, 39, 57, 34, 33, 52, 26, 22, 46, 92, 16,
56, 31, 81, 70, 14, 36, 59, 1, 55, 92, 15, 86, 2)
# cumulative sums
running <- cumsum(values)
# predetermined target
cutoff <- 300
# last value less than target
tail(running[which(running < cutoff)],1)
#> [1] 299
# its position
length(running[which(running < cutoff)])
#> [1] 7
# sequence of the values below the cutoff
values[which(running < cutoff)]
#> [1] 21 63 39 57 34 33 52
Created on 2021-01-04 by the reprex package (v0.3.0.9001)