(Adapted from [this deleted question](https://stackoverflow.com/questions/46693934/efficient-way-to-get-the-sum-of-left-and-right-values-of-an-array-using-just-a).)

Suppose we have an array `int a[n]` and we have a pointer to an element in the middle of the array (i.e. `int *p = &a[y]` with 0 < y < n-1).

If `p` is passed into a function where we don't have direct access to the array, how can I access the elements immediately before and after the given array element so that they can be added together?

For example, if `a` is in scope the sum can be gotten easily like this:

```
int sum = a[y-1] + a[y+1];

```

But in a function where `a` is not in scope:

```
int sum_prev_next(int *p)
{
   ...
}

```

Called like this:

```
sum = sum_prev_next(&a[y]);

```

How can this function access the previous and next elements to return the sum?