#!/bin/python
#https://www.hackerrank.com/challenges/summing-the-n-series/problem

I confess, this took me a little longer to solve than it probably should have
to solve it the fast way. I solved it a bunch of slow ways before it occured to
me to think harder...
But to be fair and in my favor at least
I realized very quickly that it was just a sum of odd numbers
where n=1,2,3,4,5,6...
	1+3+5+7+9+....
So n=1 was 1, n=2 was 4=1+3, n=3 was 8=1+3+5 and so on and on...
I also realized very quickly that to find the nth number
was simple bit manipulation since it's just 2n-1 it could
be found using (n<<1)-1
Then, silly me thought to naivly add odd n's up to that point
doing a simple backwards summation so if n was 6 I'd add
11+9+7+5+3+1. But that was silly! And slow...
Finally it hit me...it's a summation! DUUUH!
Look at summing evens and odds! 11+1=12,9+3=12,7+5=12...
If n is even, it's as simple as multiplying half of n by 12 (in this case).
If n is odd, do the same thing but find the middle n and add it to the sum. 
The middle can also be found with bit manipulation since the middle n can
be found with the same trick as the last n.

Submitting this code I recieved the full 20 points! Yaay! (Some of the
other code submitted before that I would get close but this code worked
on all test cases and didn't time out.




#
# Complete the summingSeries function below.
#


def summingSeries(n):
    #
    # Write your code here.
    #
    n=n%1000000007
    if n==1:
        return 1
    m=int(n/2)
    nevenOrodd=n%2
    z=((n<<1)-1)
    #print(z)
    if nevenOrodd==0: #even
        ans=(z+1)*m
    else: #odd
        ans=(z+1)*m + ((m+1)<<1)-1
    return ans%1000000007
    


