Not the best, but. Formula in B3 dragged right:
B3
=LET(a,TAKE(FILTER($A$2:A2,$A$1:A1=1),1,-3),IF(COUNTA(a)>=3,SUM(a),0))
Result: