C # Code for Sum of array elements that is first continuously increasing then decreasing
using System ; class GFG { public static int arraySum ( int [ ] arr , int n ) { int x = ( n + 1 ) / 2 ; return ( arr [ 0 ] - 1 ) * n + x * x ; }