Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30804.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BUG", "BUG\BUG.csproj", "{417B1F1C-99DF-4941-93D4-6A8E480737F7}"
EndProject
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BUG
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] niz, niz2;
            double Sum = 0;
            Console.WriteLine("Unesite duzinu niza N i k");
            niz = Console.ReadLine().Split();
            int n = int.Parse(niz[0]);
            int k = int.Parse(niz[1]);
            int[] A = new int[n];
            Console.WriteLine("Unesite elemente niza A");
            niz2 = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
                A[i] = int.Parse(niz2[i]);
            if (k == 0)
                for (int i = 0; i < n; i++)
                    Sum += A[i];
            else
            {
                for (int j = 0; j < n; j++)
                    for (int m = n; m > j; m--)
                        for (int i = j; i < m; i++)
                            Sum += A[i];
            }
            Sum %= (Math.Pow(10, 9) + 7);
            Console.WriteLine("Pobednik: " + Sum.ToString());
            Console.ReadKey();
        }
    }
}