#include long long int inf = 1000000000000000000; long long int seg[400005], lazy[400005], ss; long long int min(long long int a, long long int b) { if (a < b) return a; else return b; } long long int get(long long int l, long long int r, long long int k, long long int left, long long int right) { seg[k] += lazy[k]; if (2 * k + 2 < 2 * ss - 1) { lazy[2 * k + 1] += lazy[k]; lazy[2 * k + 2] += lazy[k]; } lazy[k] = 0; if (right <= l || r < left) return inf; if (l <= left && right <= r + 1) return seg[k]; long long int v1 = get(l, r, 2 * k + 1, left, (left + right) / 2); long long int v2 = get(l, r, 2 * k + 2, (left + right) / 2, right); return min(v1, v2); } void set(long long int l, long long int r, long long int v, long long int k, long long int left, long long int right) { if (right <= l || r < left) return; if (l <= left && right <= r + 1) { seg[k] += lazy[k] + v; if (2 * k + 2 < 2 * ss - 1) { lazy[2 * k + 1] += lazy[k] + v; lazy[2 * k + 2] += lazy[k] + v; } lazy[k] = 0; return; } set(l, r, v, 2 * k + 1, left, (left + right) / 2); set(l, r, v, 2 * k + 2, (left + right) / 2, right); seg[k] = min(seg[2 * k + 1], seg[2 * k + 2]); return; } int main() { long long int n; scanf("%lld", &n); long long int i; ss = 1; while (ss < n) ss *= 2; for (i = 0; i < 2 * ss - 1; i++) { seg[i] = inf; lazy[i] = 0; } for (i = 0; i < n; i++) scanf("%lld", &seg[i + ss - 1]); for (i = ss - 2; i >= 0; i--) seg[i] = min(seg[2 * i + 1], seg[2 * i + 2]); long long int q; scanf("%lld", &q); long long int k, l, r, c; for (i = 0; i < q; i++) { scanf("%lld %lld %lld %lld", &k, &l, &r, &c); l--; r--; if (k == 1) set(l, r, c, 0, 0, ss); else printf("%lld\n", get(l, r, 0, 0, ss)); } return 0; }