It depends entirely on what the data in the two arrays refers to.
You could just chop off the last 1000 rows from S, but I assume that is too simplistic. How to the 5000 rows in S correspond to the 4000 rows in F? Do they cover the same range, but one has smaller sample rate than the other? Do they cover completely different ranges? Partially overlapping ranges? etc. Depending on the answers different approaches would be needed.