#15. 数组前两项求和及边界处理

    ID: 15 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatArray-1gesp1条件结构数学基础

数组前两项求和及边界处理

Sum of First Two Elements

Background

Congcong is currently learning about array operations and has encountered a simple problem that requires careful handling of edge cases.

Problem Description

Given an array of integers, return the sum of the first two elements in the array. If the array length is less than 22, just sum up the elements that exist, returning 00 if the array is length 00.

Input Format

Input is given from standard input in the following format.

A single line containing several space-separated integers.

Output Format

Output is printed to standard output in the following format.

A single integer, representing the calculated sum.

Sample

1 2 3
3
1 1
2
1 1 1 1
2

Sample Explanation

For the first sample, the array is [1, 2, 3]. The first two elements are 11 and 22, and their sum is 1+2=31 + 2 = 3. For the second sample, the array is [1, 1]. The first two elements are 11 and 11, and their sum is 1+1=21 + 1 = 2. For the third sample, the array is [1, 1, 1, 1]. The first two elements are 11 and 11, and their sum is 1+1=21 + 1 = 2.

Constraints

Time limit: 11 second, Memory limit: 10241024 KiB for each test case.