def lower_bound(a,x): ng,ok = -1,len(a) while ok-ng>1: m = (ng+ok)//2 if x<=a[m]: ok = m else: ng = m return ok def upper_bound(a,x): ok,ng = -1,len(a) while ng-ok>1: m = (ng+ok)//2 if x>a[m]: ok = m else: ng = m return ok import sys input = sys.stdin.buffer.readline n,k,p = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) b.sort() l,r = -1,p while r-l>1: m = (l+r)//2 cnt = 0 for i in range(n): cnt += upper_bound(b,m+p-a[i])-lower_bound(b,p-a[i])+1+upper_bound(b,m-a[i])+1 if cnt