Question: > 
> Define a function `g` with two arguments, `w` and `n`, where `w` a list of integers sorted in descending order ands `n` is an integer.; `g` should return a list produced by inserting `n` into `w` in a way that maintains descending order.
> 
> 
> 

For example `g[{9, 8, 5, 3, 2, 1}, 6]` must return `{9, 8, 6, 5, 3, 2, 1}`.

How cam I do this in the best way in functional programming?

Answer: 
I filed a bug report for you. Here is a workaround:

```
Needs["NDSolve`FEM`"]
F[x_, y_] = 2*(Cos[x] + Cos[y]);
s1 = ImplicitRegion[F[x, y] == 1, {{x, -Pi, Pi}, {y, -Pi, Pi}}];
bmesh = ToBoundaryMesh[s1, "MeshOrder" -> 2];
FEMNBoundaryIntegrate[Cos[x], {x, y}, bmesh]
3.131461968054968`

```

*update*:

You can also use this:

```
Needs["NDSolve`FEM`"]
F[x_, y_] = 2*(Cos[x] + Cos[y]);
s1 = ImplicitRegion[F[x, y] == 1, {{x, -Pi, Pi}, {y, -Pi, Pi}}];
bmesh = ToBoundaryMesh[s1, "MeshOrder" -> 2];
NIntegrate[Cos[x], {x, y} \[Element] bmesh]

```

Generate a boundary element mesh (see [ToBoundaryMesh](https://reference.wolfram.com/language/FEMDocumentation/ref/ToBoundaryMesh.html)) from the region. `NIntegrate` than figures out that it should do a surface integral.
Some things change to better. In version 13 on Windows 10

```
F[x_, y_] = 2*(Cos[x] + Cos[y]);
s1 = ImplicitRegion[F[x, y] == 1, {{x, -Pi, Pi}, {y, -Pi, Pi}}];
NIntegrate[Cos[x], Element[{x, y}, s1]]

```

> 
> `3.13146`
> 
> 
> 

```
Region[s1]

```

[![enter image description here](https://i.stack.imgur.com/D4GFn.png)](https://i.stack.imgur.com/D4GFn.png)

It should be noticed that the notation `Integrate[Cos[x], Element[{x, y}, s1]]` is unclear. Is this a line integral? if so, of which kind?

Addition. I'd like to add that

```
Integrate[Cos[x]*Boole[2*(Cos[x] + Cos[y]) == 1], {x, -Pi, Pi}, {y, -Pi, Pi}]

```

> 
> `0`
> 
> 
> 

in order to explain why the notation `Integrate[Cos[x], Element[{x, y}, s1]]` is unclear.