#include <bits/stdc++.h>   using namespace std;   inline int lowbit(int x) { return x & -x; }   inline int ABS(int x) { return x < 0 ? -x : x; }   inline long long ABS(long long x) { return x < 0 ? -x : x; }   inline void MAX(int &a, int b) {     if (b > a) a = b;   }   inline void MAX(long long &a, long long b) {     if (b > a) a = b;   }   inline void MIN(int &a, int b) {     if (b < a) a = b;   }   inline void MIN(long long &a, long long b) {     if (b < a) a = b;   }   inline void SUM(int &a, int b) { a = (a + b) % 1000000007; }   int fast(int x, int v) {     int ans = 1;     for (; v; v >>= 1, x = (long long)x * x % 1000000007)       if (v & 1) ans = (long long)ans * x % 1000000007;     return ans;   }   long long fast(long long x, long long v) {     long long ans = 1;     for (; v; v >>= 1, x = x * x % 1000000007)       if (v & 1) ans = ans * x % 1000000007;     return ans;   }   inline long long sqr(int x) { return x * x; }   int n, a[300005], l, r, sum;   long long pre[300005], ans;   map<int, int> s;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %d , a + i);       pre[i] = pre[i - 1] + (a[i] < 0 ? 0 : a[i]);       if (!s[a[i]]) s[a[i]] = i;     }     ans = -0x7f7f7f7f;     for (int i = n; i >= 1; --i)       if (s[a[i]] && s[a[i]] != i && pre[i - 1] - pre[s[a[i]]] + a[i] * 2 > ans) {         ans = pre[i - 1] - pre[s[a[i]]] + a[i] * 2;         l = s[a[i]];         r = i;       }     for (int i = l + 1; i <= r - 1; ++i)       if (a[i] < 0) ++sum;     printf( %I64d %d n , ans, sum + l - 1 + n - r);     for (int i = 1; i <= l - 1; ++i) printf( %d  , i);     for (int i = l + 1; i <= r - 1; ++i)       if (a[i] < 0) printf( %d  , i);     for (int i = r + 1; i <= n; ++i) printf( %d  , i);   }   