Answer: provided in the explanation section
Explanation:
import java.util.*;
class Mutation {
public static int[] mutateTheArray(int n , int[] a)
{
int []b = new int[n];
for(int i=0;i<n;i++)
{
b[i]=0;
if(((i-1)>=0)&&((i-1)<n))
b[i]+=a[i-1];
if(((i)>=0)&&((i)<n))
b[i]+=a[i];
if(((i+1)>=0)&&((i+1)<n))
b[i]+=a[i+1];
}
return b;
}
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int n= sc.nextInt();
int []a = new int [n];
for(int i=0;i<n;i++)
a[i]=sc.nextInt();
int []b = mutateTheArray(n,a);
for(int i=0;i<n;i++)
System.out.print(b[i]+" ");
}
}
cheers i hope this helped !!