Fox Ciel is playing a game with numbers now. 

Ciel has *n* positive integers: *x*<sub class="lower-index">1</sub>, *x*<sub class="lower-index">2</sub>, ..., *x*<sub class="lower-index">*n*</sub>. She can do the following operation as many times as needed: select two different indexes *i* and *j* such that *x*<sub class="lower-index">*i*</sub> &gt; *x*<sub class="lower-index">*j*</sub> hold, and then apply assignment *x*<sub class="lower-index">*i*</sub> = *x*<sub class="lower-index">*i*</sub> - *x*<sub class="lower-index">*j*</sub>. The goal is to make the sum of all numbers as small as possible.

Please help Ciel to find this minimal sum.
The first line contains an integer *n* (2 ≤ *n* ≤ 100). Then the second line contains *n* integers: *x*<sub class="lower-index">1</sub>, *x*<sub class="lower-index">2</sub>, ..., *x*<sub class="lower-index">*n*</sub> (1 ≤ *x*<sub class="lower-index">*i*</sub> ≤ 100).
#include<stdio.h>
#include<math.h>
int main()
{
    int n,i,j,k,p,sum=0,c=0,t;
    scanf("%d",&n);
    int x[n];
    for(i=0;i<n;i++)
        scanf("%d",&x[i]);
            for(i=0;i<n;i++){
            for(j=i+1;j<n;j++){
                if(x[j]<x[i]){
                    t=x[i];x[i]=x[j];x[j]=t;
                }}}
    while(x[0]!=x[n-1]){
    for(i=0;i<n;i++){
            for(j=i+1;j<n;j++){
                if(x[j]<x[i]){
                    t=x[i];x[i]=x[j];x[j]=t;
                }}}
    p=x[0];
    for(i=0;i<n;i++){
        if(p<x[i])
            x[i]=x[i]-p;
    }}
    for(i=0;i<n;i++)
        sum+=x[i];
    printf("%d",sum);
    return 0;
}
