class Solution {
public int pairSum(ListNode head) {
ArrayList<Integer> li=new ArrayList<>();
while(head!=null){
li.add(head.val);
head=head.next;
}
int res=Integer.MIN_VALUE;
int left=0,right=li.size()-1;
while(left<right){
res=Math.max(res,li.get(left)+li.get(right));
left++;
right--;
}
return res;
}
}
class Solution(object):
def pairSum(self, head):
li=[]
while head:
li.append(head.val)
head=head.next
res=-sys.maxint-1
left,right=0,len(li)-1
while left<right:
res=max(res,li[left]+li[right])
left+=1
right-=1
return res