#include <bits/stdc++.h>
using namespace std;
typedef struct {
  int ss;
  int ff;
  int rr;
  int cc;
} inp;
inp in[250005];
int a[405];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  srand(time(NULL));
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    cin >> in[i].ss >> in[i].ff >> in[i].cc >> in[i].rr;
  }
  reverse(in + 1, in + 1 + m);
  int ms = 0, mf = 0, mc = 0, mr = 0;
  for (int i = 1; i <= m; i++) {
    int s = in[i].ss, f = in[i].ff, c = in[i].cc, r = in[i].rr;
    int cur = s;
    if (a[mf] - a[ms] >= a[f] - a[s] && c <= mc && r >= mr) continue;
    for (int j = 0; j <= r; j++) {
      long long LL = s, RR = n;
      while (LL != RR) {
        long long midd = (LL + RR + 1) / 2;
        if (1LL * (a[midd] - a[cur]) * c <= ans)
          LL = midd;
        else
          RR = midd - 1;
      }
      cur = LL;
      if (cur >= f) break;
    }
    if (cur >= f) continue;
    long long L = cur, R = 1e18;
    while (L != R) {
      long long mid = (L + R) / 2;
      cur = s;
      for (int j = 0; j <= r; j++) {
        long long LL = s, RR = n;
        while (LL != RR) {
          long long midd = (LL + RR + 1) / 2;
          if (1LL * (a[midd] - a[cur]) * c <= mid)
            LL = midd;
          else
            RR = midd - 1;
        }
        cur = LL;
        if (cur >= f) break;
      }
      if (cur >= f)
        R = mid;
      else
        L = mid + 1;
    }
    ans = L;
    ms = s;
    mf = f;
    mc = c;
    mr = r;
  }
  cout << ans;
}
