I tried it myself, but I can't finish it. I can't figure out how to find the sum of elements on a segment. And is there any method for this?
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("the length of array");
int n = Convert.ToInt32(Console.ReadLine());
int[] array = new int[n];
for (var i = 0; i < array.Length; i++)
{
array[i] = Convert.ToInt32(Console.ReadLine());
}
int a = Convert.ToInt32(Console.ReadLine());
int b = Convert.ToInt32(Console.ReadLine());
for (int i = a; i <= b; i++)
{
}
}
}
}