In yesterday’s weekend contest at coding ninja’s platform, in the first problem named Minimize Bill when I tried to submit the first code it showed me the **Partially Accepted** but when I submited the editorialist code after the contest it showed me **Accepted**. I think the logic of two solutions are almost similar. Can anyone please tell me why my code fails?

```
// My solution
long long int totalBill(int n, vector<int> &a)
{
sort(a.begin(), a.end());
int maxx = a[n - 1];
long long int sum = 0;
for (long long int i = 0; i < n - 1; i++)
{
sum = sum + a[i];
}
long long int ans = sum - maxx;
return ans;
}
```

```
// Editorialist Solution
long long int totalBill(int n, vector<int> &a)
{
int maxx = a[0];
long long int sum = 0;
for(long long int i = 0; i < n; i++)
{
maxx = max(maxx, a[i]);
sum = sum + a[i];
}
long long int ans = sum - (2 * maxx);
return ans;
}
```

What is the difference between the logic of this two codes?