#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     long long arr[n];     for (int i = 0; i < n; i++) scanf( %lld , &arr[i]);     map<long long, int> mp;     long long sum = 0;     for (int i = n - 1; i >= 0; i--) {       sum += arr[i];       mp[sum] = i;     }     long long ans = 0;     long long cnt = 0;     for (int i = 0; i < n; i++) {       cnt += arr[i];       if (mp[cnt] > i && mp[cnt] != 0) {         ans = max(cnt, ans);       }     }     cout << ans << endl;   }   