Problem:
Score : 200 points

Problem Statement

Determine if an N-sided polygon (not necessarily convex) with sides of length L_1, L_2, ..., L_N can be drawn in a two-dimensional plane.

You can use the following theorem:

Theorem: an N-sided polygon satisfying the condition can be drawn if and only if the longest side is strictly shorter than the sum of the lengths of the other N-1 sides.

Constraints

All values in input are integers.

3 \leq N \leq 10

1 \leq L_i \leq 100

Input

Input is given from Standard Input in the following format:

N
L_1 L_2 ... L_N

Output

If an N-sided polygon satisfying the condition can be drawn, print Yes; otherwise, print No.

Sample Input 1

4
3 8 5 1

Sample Output 1

Yes

Since 8 < 9 = 3 + 5 + 1, it follows from the theorem that such a polygon can be drawn on a plane.

Sample Input 2

4
3 8 4 1

Sample Output 2

No

Since 8 \geq 8 = 3 + 4 + 1, it follows from the theorem that such a polygon cannot be drawn on a plane.

Sample Input 3

10
1 8 10 5 8 12 34 100 11 3

Sample Output 3

No

Solution in C (GCC 5.4.1) (judge verdict: Accepted)

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int array[20];
int buffer[20];
int N;

void bubbleSort()
{
  int flag = 1;
  int tmp;
  while (flag)
  {
    flag = 0;
    for (int i = 0; i < N - 1; i++)
    {
      if (array[i] > array[i + 1])
      {
        tmp = array[i + 1];
        array[i + 1] = array[i];
        array[i] = tmp;
        flag = 1;
      }
    }
  }
}

void mergeSort(int start, int end)
{
  if (end - start <= 0)
  {
    return;
  }

  int half = (start + end) / 2;

  mergeSort(start, half);
  mergeSort(half + 1, end);

  for (int i = 0; i <= half - start; i++)
  {
    buffer[i] = array[start + i];
  }

  int push_pointer = start, first_half_pointer = 0, second_half_pointer = half + 1;
  while (first_half_pointer <= half - start && second_half_pointer <= end)
  {
    if (buffer[first_half_pointer] < array[second_half_pointer])
    {
      array[push_pointer] = buffer[first_half_pointer];
      first_half_pointer++;
    }
    else
    {
      array[push_pointer] = array[second_half_pointer];
      second_half_pointer++;
    }
    push_pointer++;
  }
  while (first_half_pointer <= half - start)
  {
    array[push_pointer++] = buffer[first_half_pointer++];
  }
  while (second_half_pointer <= end)
  {
    array[push_pointer++] = array[second_half_pointer++];
  }
}

int main()
{
  scanf("%d", &N);
  for (int i = 0; i < N; i++)
  {
    scanf("%d", &array[i]);
  }
  // bubbleSort();
  mergeSort(0, N - 1);
  int sum = 0;
  for (int i = 0; i < N - 1; i++)
  {
    sum += array[i];
  }
  if (sum > array[N - 1])
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
}