public static int getSum(int n, long x0, long a, long b) {
		int totalRadii = 0;
		long prevElement = x0;
		for (int index = 1; index < n - 1; index++) {
			long currElement = getSeriesElement(index, a, b, prevElement);
			long prev = x0;
			long curr;
			int maxRadii = (index <= n/2) ? index : (n-1)-index;
			for(int radiiIndex=0; radiiIndex <= index+maxRadii; radiiIndex++){

				if(radiiIndex == 0){
					curr = x0;
				}else {
					curr = getSeriesElement(radiiIndex, a, b, prev);
				}

				if((radiiIndex != index) && ((radiiIndex >= index - maxRadii) || (radiiIndex <= index + maxRadii))){
					if(curr >= currElement){
						maxRadii = Math.abs(index - radiiIndex)-1;
					}else{
						maxRadii = Math.abs(index - radiiIndex);
					}

				}

				prev = curr;
			}
			/*System.out.println("**********************");
			System.out.println("Adding to Total Radii");
			System.out.println("TotalRadii before = "+totalRadii);
			System.out.println("Current Element from Array = "+currElement);
			System.out.println("Index = "+index);
			System.out.println("maxRadii = "+maxRadii);*/
			totalRadii += maxRadii;
			/*System.out.println("TotalRadii after = "+totalRadii);
			System.out.println("**********************");*/
			prevElement = currElement;
		}
		return (int)totalRadii%1000000007;
	}