Learn DSADSAContests
coding75 logo
LeetCode POTDPOTDSheets
coding75 Pro
coding75 logo
Dashboard
Learn DSA
Course RoadmapFlow
DSA Topic TreeNew πŸš€
Contest SolutionsPractice
Practice Sheets
MasterclassesLive πŸ‘¨πŸ»β€πŸ’»

coding75 ProPRO

Live Classes & Placement Guidance

coding75 logo

The premier developer platform for mastering Data Structures & Algorithms, exploring contest editorials, building ATS-ready resumes, and accelerating your tech career.

Connect & Community

DSA & Contests

  • Learn DSA
  • Contest Solutions
  • LeetCode POTDDaily
  • Practice Sheets
  • MasterclassesSoon

Interview Prep

  • Portfolio Projects
  • CS Fundamentals
  • System DesignSoon
  • Interview ExperiencesSoon
  • Mock InterviewsSoon

Career & Pro

  • Jobs & Internships
  • Resume BuilderATS
  • coding75 Pro
  • Submit Feedback
Β© 2026coding75β€’crackDSAβ„’β€’Maa Lalita Edtech Private Limited. All Rights Reserved.
Privacy PolicyTerms & ConditionsContact Support
Registered Office: Kanpur 208021β€’Regional Office: Indiranagar, Bangalore, 560008
Maa Lalita Edtech Private Limited
Contests/Codeforces/Codeforces Round 1059/A. Beautiful Average
Next
CodeforcesCodeforces
Newbie
Codeforces Round 1059

A. Beautiful Average

ArrayGreedy
Loading...
Solve on Codeforces

Problem Statement

Official algorithmic problem description and constraints.

Open on Codeforces

You are given an array π‘Ž

 of length π‘›

.

Your task is to find the maximum possible average value of any subarray

βˆ—

 of the array π‘Ž

.

Formally, for any indices π‘™,π‘Ÿ

 such that 1β‰€π‘™β‰€π‘Ÿβ‰€π‘›

, define the average of the subarray π‘Ž

𝑙

,π‘Ž

𝑙+1

,…,π‘Ž

π‘Ÿ

 as the sum of elements divided by the number of elements or:

𝚊𝚟𝚐(𝑙,π‘Ÿ)=1

π‘Ÿβˆ’π‘™+1


βˆ‘

𝑖=𝑙

π‘Ÿ

π‘Ž

𝑖

Output the maximum value of πšŠπšŸπš(𝑙,π‘Ÿ)

 over all choices of π‘™,π‘Ÿ

.

βˆ—

An array π‘

 is a subarray of an array π‘Ž

 if π‘

 can be obtained from π‘Ž

 by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end. In particular, an array is a subarray of itself.

Input


The first line contains a single integer π‘‘

 (1≀𝑑≀10

4

) β€” the number of test cases.

The first line of each testcase contains a single integer π‘›

 (1≀𝑛≀10

) β€” the length of the array π‘Ž

.

The second line of each testcase contains π‘›

 integers π‘Ž

1

,π‘Ž

2

,…,π‘Ž

𝑛

 (1β‰€π‘Ž

𝑖

≀10

) β€” the elements of the array.

Output


For each testcase, output a single integer β€” the maximum average of any subarray of the given array.

It can be shown that the answer is always an integer.

Example

Input

Copy

3
4
3 3 3 3
5
7 1 6 9 9
5
3 4 4 4 3

Output

Copy

3
9
4


Solutions & Walkthrough

Detailed video explanations, mathematical intuition, and clean C++ implementation code.

Connecting secure classroom stream...
Back to Codeforces Round 1059
Next Problem