Find the difference Between The Documents in single collection

My goal is to find two random documents. Each document has a UserCount. The usercount difference between these two document

Actually, I’m getting an output below

{
    "UserCount": 10,
    "_id": 30,
},
{
    "UserCount": 22,
    "_id": 31,
},
{
    "UserCount": 30,
    "_id": 32,
},
{
    "UserCount": 35,
    "_id": 33,
}

expecting output below.

{
    "UserCount": 10,
    "_id": 30,
    "difference" : "12",
},
{
    "UserCount": 22,
    "_id": 31,
    "difference" : "8",
},
{
    "UserCount": 30,
    "_id": 32,
    "difference" : "5",
},
{
    "UserCount": 35,
    "_id": 33,
    "difference" : "0",
}

using MongoDB query, it is very difficult to solve this problem.

It is very hard with any system because your problem is not well defined.

How do you get your differences of “12” for _id:30 ? Is it the difference between UserCount of _id:30 and UserCount of _id:31 ?

What do you mean by

Is it random? Or you want the difference between the next _id ?

If difference is the result of a subtraction why do you put it between quotes as a string?