Database

[{"id":1,x:[1,1,-1,-1,1,1,1,-1,-1,-1,-1]},{"id":2,x:[1,-1,-1,1,1,1,-1]}]

Query

db.collection.aggregate({"$project":{"_id":0,"id":1,"x":{"$max":{"$map":{"input":{$split:[{"$reduce":{"input":"$x","initialValue":"","in":{$concat:["$$value",{"$cond":[{"$gt":["$$this",0]},"p","n"]}]}}},"p"]},"in":{"$strLenBytes":"$$this"}}}}}})

Result